]> gitweb.factorcode.org Git - factor.git/blobdiff - 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
index 7bfe238fa83515dbbc0a1ef263dfa48088abad82..9b647bc5c648af9719fcc2fae694d085a7e4ebf6 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators combinators.smart fry lexer quotations
-sequences slots  ;
+sequences slots words ;
 IN: slots.syntax
 
 SYNTAX: slots[
@@ -11,3 +11,15 @@ SYNTAX: slots[
 SYNTAX: slots{
     "}" [ reader-word 1quotation ] map-tokens
     '[ [ _ cleave ] output>array ] append! ;
+
+: writer-word* ( name -- word )
+    ">>" prepend "accessors" lookup ;
+
+SYNTAX: set-slots[
+    "]" [ writer-word* 1quotation ] map-tokens
+    '[ _ spread ] append! ;
+
+SYNTAX: set-slots{
+    "}" [ writer-word* 1quotation ] map-tokens
+    [ length ] [ ] bi
+    '[ _ firstn _ spread ] append! ;