1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax ;
7 { $description "Outputs several slot values to the stack." }
8 { $example "USING: kernel prettyprint slots.syntax ;"
9 "IN: slots.syntax.example"
10 "TUPLE: rectangle width height ;"
11 "T{ rectangle { width 3 } { height 5 } } slots[ width height ] [ . ] bi@"
17 { $description "Outputs an array of slot values from a tuple." }
18 { $example "USING: prettyprint slots.syntax ;"
19 "IN: slots.syntax.example"
20 "TUPLE: rectangle width height ;"
21 "T{ rectangle { width 3 } { height 5 } } slots{ width height } ."
26 { $description "Sets slot values in a tuple from an array." }
27 { $example "USING: prettyprint slots.syntax kernel ;"
28 "IN: slots.syntax.example"
29 "TUPLE: rectangle width height ;"
30 "rectangle new { 3 5 } set-slots{ width height } ."
31 "T{ rectangle { width 3 } { height 5 } }"
35 { $description "Sets slot values in a tuple from the stack." }
36 { $example "USING: prettyprint slots.syntax kernel ;"
37 "IN: slots.syntax.example"
38 "TUPLE: rectangle width height ;"
39 "rectangle new 3 5 set-slots[ width height ] ."
40 "T{ rectangle { width 3 } { height 5 } }"
43 ARTICLE: "slots.syntax" "Slots syntax sugar"
44 "The " { $vocab-link "slots.syntax" } " vocabulary provides an alternative syntax for getting and setting multiple values of a tuple." $nl
45 "Syntax sugar for cleaving slots to the stack:"
46 { $subsections POSTPONE: slots[ }
47 "Cleaving slots to an array:"
48 { $subsections POSTPONE: slots{ }
49 "Setting slots from the stack:"
50 { $subsections POSTPONE: set-slots[ }
51 "Setting slots from an array:"
52 { $subsections POSTPONE: set-slots{ } ;