]> gitweb.factorcode.org Git - factor.git/blob - core/generic/slots.facts
more sql changes
[factor.git] / core / generic / slots.facts
1 USING: generic help kernel-internals parser words ;
2
3 HELP: define-typecheck
4 { $values { "class" "a class word" } { "generic" "a generic word" } { "quot" "a quotation" } }
5 { $description
6     "Defines a generic word with the " { $link standard-combination } " using dispatch position 0, and having one method on " { $snippet "class" } "."
7     $terpri
8     "This creates a definition analogous to the following code:"
9     { $code
10         "GENERIC: generic"
11         "M: class generic quot ;"
12     }
13     "It checks if the top of the stack is an instance of " { $snippet "class" } ", and if so, executes the quotation. Delegation is respected."
14 }
15 { $notes "This word is used internally to wrap low-level code that does not do type-checking in safe user-visible words." } ;
16
17 HELP: define-slot-word
18 { $values { "class" "a class word" } { "slot" "a positive integer" } { "word" "a new word" } { "quot" "a quotation" } }
19 { $description "Defines " { $snippet "word" } " to be a simple type-checking generic word that receives the slot number on the stack as a fixnum." }
20 $low-level-note ;
21
22 HELP: reader-effect
23 { $values { "effect" "an instance of " { $link effect } } }
24 { $description "The stack effect of slot reader words is " { $snippet "( obj -- value )" } "." } ;
25
26 HELP: define-reader
27 { $values { "class" "a class word" } { "slot" "a positive integer" } { "decl" "a class word or " { $link f } } { "reader" "a word" } }
28 { $description "Defines a generic word " { $snippet "reader" } " to read a slot from instances of " { $snippet "class" } ". If " { $snippet "decl" } " is not " { $link f } ", then " { $link declare } " is applied to the slot value to declare that the value is an instance of a specific class." }
29 $low-level-note ;
30
31 HELP: define-writer
32 { $values { "class" "a class word" } { "slot" "a positive integer" } { "writer" "a word" } }
33 { $description "Defines a generic word " { $snippet "writer" } " to write a new value to a slot in instances of " { $snippet "class" } "." }
34 $low-level-note ;
35
36 HELP: define-slot
37 { $values { "class" "a class word" } { "slot" "a positive integer" } { "decl" "a class word or " { $link f } } { "reader" "a word" } { "writer" "a word" } }
38 { $description "Defines a pair of generic words, " { $snippet "reader" } " and " { $snippet "writer" } " for reading and writing a slot value in instances of " { $snippet "class" } "." }
39 $low-level-note ;
40
41 HELP: define-slots
42 { $values { "class" "a class word" } { "spec" "a sequence of triples" } }
43 { $description
44     "Defines a set of slot accessor/mutator words."
45     $terpri
46     "Each entry in the " { $snippet "spec" } " sequence is a three-element sequence with the following elements:"
47     { $list
48         "a slot number"
49         { "a reader word, or " { $link f } }
50         { "a writer word, or " { $link f } }
51     }
52     "If the reader or writer is " { $link f } ", the corresponding word is not defined."
53 }
54 $low-level-note ;
55
56 HELP: simple-slots
57 { $values { "class" "a class word" } { "slots" "a sequence of strings" } { "base" "a slot number" } }
58 { $description "Constructs a slot specification for " { $link define-slots } " where each slot is named by an element of " { $snippet "slots" } " prefixed by the name of the class. Slots are numbered consecutively starting from " { $snippet "base" } ". Reader and writer words are defined in the current vocabulary, with the reader word having the same name as the slot, and the writer word name prefixed by " { $snippet "\"set-\"" } "." }
59 { $notes "This word is used by " { $link define-tuple } " and " { $link POSTPONE: TUPLE: } "." } ;