]> gitweb.factorcode.org Git - factor.git/blob - extra/slots/syntax/syntax.factor
Add set-slots{ and set-slots[ words in slots.syntax and document them.
[factor.git] / extra / slots / syntax / syntax.factor
1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators combinators.smart fry lexer quotations
4 sequences slots words ;
5 IN: slots.syntax
6
7 SYNTAX: slots[
8     "]" [ reader-word 1quotation ] map-tokens
9     '[ _ cleave ] append! ;
10
11 SYNTAX: slots{
12     "}" [ reader-word 1quotation ] map-tokens
13     '[ [ _ cleave ] output>array ] append! ;
14
15 : writer-word* ( name -- word )
16     ">>" prepend "accessors" lookup ;
17
18 SYNTAX: set-slots[
19     "]" [ writer-word* 1quotation ] map-tokens
20     '[ _ spread ] append! ;
21
22 SYNTAX: set-slots{
23     "}" [ writer-word* 1quotation ] map-tokens
24     [ length ] [ ] bi
25     '[ _ firstn _ spread ] append! ;