Documentation updates suggested by dmpk2k
parent
9efa1e0c31
commit
a0ba66080d
|
@ -49,6 +49,7 @@ $nl
|
|||
{ "associative mapping" { "an object whose class implements the " { $link "assocs-protocol" } } }
|
||||
{ "boolean" { { $link t } " or " { $link f } } }
|
||||
{ "class" { "a set of objects identified by a " { $emphasis "class word" } " together with a discriminating predicate. See " { $link "classes" } } }
|
||||
{ "combinator" { "a word taking a quotation or another word as input; a higher-order function. See " { $link "combinators" } } }
|
||||
{ "definition specifier" { "an instance of " { $link definition } " which implements the " { $link "definition-protocol" } } }
|
||||
{ "generalized boolean" { "an object interpreted as a boolean; a value of " { $link f } " denotes false and anything else denotes true" } }
|
||||
{ "generic word" { "a word whose behavior depends can be specialized on the class of one of its inputs. See " { $link "generic" } } }
|
||||
|
@ -56,6 +57,7 @@ $nl
|
|||
{ "object" { "any datum which can be identified" } }
|
||||
{ "ordering specifier" { "see " { $link "order-specifiers" } } }
|
||||
{ "pathname string" { "an OS-specific pathname which identifies a file" } }
|
||||
{ "quotation" { "an anonymous function; an instance of the " { $link quotation } " class. More generally, instances of the " { $link callable } " class can be used in many places documented to expect quotations" } }
|
||||
{ "sequence" { "a sequence; see " { $link "sequence-protocol" } } }
|
||||
{ "slot" { "a component of an object which can store a value" } }
|
||||
{ "stack effect" { "a pictorial representation of a word's inputs and outputs, for example " { $snippet "+ ( x y -- z )" } ". See " { $link "effects" } } }
|
||||
|
|
|
@ -92,7 +92,7 @@ ARTICLE: "tuple-constructors" "Tuple constructors"
|
|||
$nl
|
||||
"Constructors play a part in enforcing the invariant that slot values must always match slot declarations. The " { $link new } " word fills in the tuple with initial values, and " { $link boa } " ensures that the values on the stack match the corresponding slot declarations. See " { $link "tuple-declarations" } "."
|
||||
$nl
|
||||
"All tuple construction should be done through constructor words, and construction primitives should be encapsulated and never called outside of the vocabulary where the class is defined, because this encourages looser coupling. For example, a constructor word could be changed to use memoization instead of always constructing a new instance, or it could be changed to construt a different class, without breaking callers."
|
||||
"All tuple construction should be done through constructor words, and construction primitives should be encapsulated and never called outside of the vocabulary where the class is defined, because this encourages looser coupling. For example, a constructor word could be changed to use memoization instead of always constructing a new instance, or it could be changed to construct a different class, without breaking callers."
|
||||
$nl
|
||||
"Examples of constructors:"
|
||||
{ $code
|
||||
|
@ -220,13 +220,13 @@ ARTICLE: "tuple-examples" "Tuple examples"
|
|||
" <employee> \"project manager\" >>position ;" }
|
||||
"An alternative strategy is to define the most general BOA constructor first:"
|
||||
{ $code
|
||||
": <employee> ( name position -- person )"
|
||||
": <employee> ( name position -- employee )"
|
||||
" 40000 employee boa ;"
|
||||
}
|
||||
"Now we can define more specific constructors:"
|
||||
{ $code
|
||||
": <manager> ( name -- person )"
|
||||
" \"manager\" <person> ;" }
|
||||
": <manager> ( name -- employee )"
|
||||
" \"manager\" <employee> ;" }
|
||||
"An example using reader words:"
|
||||
{ $code
|
||||
"TUPLE: check to amount number ;"
|
||||
|
@ -256,7 +256,7 @@ ARTICLE: "tuple-examples" "Tuple examples"
|
|||
": next-position ( role -- newrole )"
|
||||
" positions [ index 1+ ] keep nth ;"
|
||||
""
|
||||
": promote ( person -- person )"
|
||||
": promote ( employee -- employee )"
|
||||
" [ 1.2 * ] change-salary"
|
||||
" [ next-position ] change-position ;"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue