From 18cc66f64ef27cbba1d9dfb43c73817772e339da Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 5 Sep 2008 20:50:07 -0500 Subject: [PATCH] Update docs --- core/syntax/syntax-docs.factor | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index 57dec876a5..cd76967e5a 100755 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -284,10 +284,31 @@ HELP: C{ HELP: T{ { $syntax "T{ class slots... }" } -{ $values { "class" "a tuple class word" } { "slots" "list of objects" } } -{ $description "Marks the beginning of a literal tuple. Literal tuples are terminated by " { $link POSTPONE: } } "." +{ $values { "class" "a tuple class word" } { "slots" "slot values" } } +{ $description "Marks the beginning of a literal tuple." $nl -"The class word must always be specified. If an insufficient number of values is given after the class word, the remaining slots of the tuple are set to " { $link f } ". If too many values are given, they are ignored." } ; +"Three literal syntax forms are recognized:" +{ $list + { "empty tuple form: if no slot values are specified, then the literal tuple will have all slots set to their initial values (see " { $link "slot-initial-values" } ")." } + { "BOA-form: if the first element of " { $snippet "slots" } " is " { $snippet "f" } ", then the remaining elements are slot values corresponding to slots in the order in which they are defined in the " { $link POSTPONE: TUPLE: } " form." } + { "assoc-form: otherwise, " { $snippet "slots" } " is interpreted as a sequence of " { $snippet "{ slot-name value }" } " pairs. The " { $snippet "slot-name" } " should not be quoted." } +} +"BOA form is more concise, whereas assoc form is more readable for larger tuples with many slots, or if only a few slots are to be specified." +$nl +"With BOA form, specifying an insufficient number of values is given after the class word, the remaining slots of the tuple are set to their initial values (see " { $link "slot-initial-values" } "). If too many values are given, an error will be raised." } +{ $examples +"An empty tuple; since vectors have their own literal syntax, the above is equivalent to " { $snippet "V{ }" } "" +{ $code "T{ vector }" } +"A BOA-form tuple:" +{ $code + "USE: colors" + "T{ rgba f 1.0 0.0 0.5 }" +} +"An assoc-form tuple equal to the above:" +{ $code + "USE: colors" + "T{ rgba { red 1.0 } { green 0.0 } { blue 0.5 } }" +} } ; HELP: W{ { $syntax "W{ object }" }