1 USING: generic help kernel-internals parser words ;
4 { $values { "class" "a class word" } { "generic" "a generic word" } { "quot" "a quotation" } }
6 "Defines a generic word with the " { $link standard-combination } " using dispatch position 0, and having one method on " { $snippet "class" } "."
8 "This creates a definition analogous to the following code:"
11 "M: class generic quot ;"
13 "It checks if the top of the stack is an instance of " { $snippet "class" } ", and if so, executes the quotation. Delegation is respected."
15 { $notes "This word is used internally to wrap low-level code that does not do type-checking in safe user-visible words." } ;
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." }
23 { $values { "effect" "an instance of " { $link effect } } }
24 { $description "The stack effect of slot reader words is " { $snippet "( obj -- value )" } "." } ;
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." }
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" } "." }
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" } "." }
42 { $values { "class" "a class word" } { "spec" "a sequence of triples" } }
44 "Defines a set of slot accessor/mutator words."
46 "Each entry in the " { $snippet "spec" } " sequence is a three-element sequence with the following elements:"
49 { "a reader word, or " { $link f } }
50 { "a writer word, or " { $link f } }
52 "If the reader or writer is " { $link f } ", the corresponding word is not defined."
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: } "." } ;