1 USING: help.markup help.syntax kernel classes words
\r
2 checksums checksums.crc32 sequences math ;
\r
5 ARTICLE: "class-operations" "Class operations"
\r
6 "Set-theoretic operations on classes:"
\r
7 { $subsection class= }
\r
8 { $subsection class< }
\r
9 { $subsection class<= }
\r
10 { $subsection class-and }
\r
11 { $subsection class-or }
\r
12 { $subsection classes-intersect? }
\r
13 { $subsection min-class }
\r
14 "Low-level implementation detail:"
\r
15 { $subsection class-types }
\r
16 { $subsection flatten-class }
\r
17 { $subsection flatten-builtin-class }
\r
18 { $subsection class-types }
\r
19 { $subsection class-tags } ;
\r
21 ARTICLE: "class-linearization" "Class linearization"
\r
22 "Classes have an intrinsic partial order; given two classes A and B, we either have that A is a subset of B, B is a subset of A, A and B are equal as sets, or they are incomparable. The last two situations present difficulties for method dispatch:"
\r
24 "If a generic word defines a method on a mixin class A and another class B, and B is the only instance of A, there is an ambiguity because A and B are equal as sets; any object that is an instance of one is an instance of both."
\r
25 { "If a generic word defines methods on two union classes which are incomparable but not disjoint, for example " { $link sequence } " and " { $link number } ", there is an ambiguity because the generic word may be called on an object that is an instance of both unions." }
\r
27 "The first ambiguity is resolved with a tie-breaker that compares metaclasses. The intrinsic meta-class order, from most-specific to least-specific:"
\r
29 "Built-in classes and tuple classes"
\r
34 "This means that in the above example, the generic word with methods on a mixin and its sole instance will always call the method for the sole instance, since it is more specific than a mixin class."
\r
36 "The second problem is resolved with another tie-breaker. When performing the topological sort of classes, if there are multiple candidates at any given step of the sort, lexicographical order on the class name is used."
\r
39 { $subsection class< }
\r
40 { $subsection sort-classes }
\r
42 { $subsection rank-class } ;
\r
44 HELP: flatten-builtin-class
\r
45 { $values { "class" class } { "assoc" "an assoc whose keys are classes" } }
\r
46 { $description "Outputs a set of tuple classes whose union is the smallest cover of " { $snippet "class" } " intersected with " { $link tuple } "." } ;
\r
49 { $values { "class" class } { "assoc" "an assoc whose keys are classes" } }
\r
50 { $description "Outputs a set of builtin and tuple classes whose union is the smallest cover of " { $snippet "class" } "." } ;
\r
53 { $values { "class" class } { "seq" "an increasing sequence of integers" } }
\r
54 { $description "Outputs a sequence of builtin type numbers whose instances can possibly be instances of the given class." } ;
\r
57 { $values { "first" "a class" } { "second" "a class" } { "?" "a boolean" } }
\r
58 { $description "Tests if all instances of " { $snippet "class1" } " are also instances of " { $snippet "class2" } "." }
\r
59 { $notes "Classes are partially ordered. This means that if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class1" } ", then " { $snippet "class1 = class2" } ". Also, if " { $snippet "class1 <= class2" } " and " { $snippet "class2 <= class3" } ", then " { $snippet "class1 <= class3" } "." } ;
\r
62 { $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } }
\r
63 { $description "Outputs a linear sort of a sequence of classes. Larger classes come before their subclasses." } ;
\r
66 { $values { "first" class } { "second" class } { "class" class } }
\r
67 { $description "Outputs the smallest anonymous class containing both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;
\r
70 { $values { "first" class } { "second" class } { "class" class } }
\r
71 { $description "Outputs the largest anonymous class contained in both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;
\r
73 HELP: classes-intersect?
\r
74 { $values { "first" class } { "second" class } { "?" "a boolean" } }
\r
75 { $description "Tests if two classes have a non-empty intersection. If the intersection is empty, no object can be an instance of both classes at once." } ;
\r
78 { $values { "class" class } { "seq" "a sequence of class words" } { "class/f" "a class word or " { $link f } } }
\r
79 { $description "If all classes in " { $snippet "seq" } " that intersect " { $snippet "class" } " are subtypes of " { $snippet "class" } ", outputs the last such element of " { $snippet "seq" } ". If any conditions fail to hold, outputs " { $link f } "." } ;
\r