1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser kernel sequences words effects
4 stack-checker.transforms combinators assocs definitions
5 quotations namespaces memoize accessors ;
8 : real-macro-effect ( word -- effect' )
9 "declared-effect" word-prop in>> 1 <effect> ;
11 : define-macro ( word definition -- )
12 over "declared-effect" word-prop in>> length >r
13 2dup "macro" set-word-prop
14 2dup over real-macro-effect memoize-quot [ call ] append define
18 (:) define-macro ; parsing
20 PREDICATE: macro < word "macro" word-prop >boolean ;
22 M: macro definer drop \ MACRO: \ ; ;
24 M: macro definition "macro" word-prop ;
27 [ call-next-method ] [ f "macro" set-word-prop ] bi ;
29 : n*quot ( n seq -- seq' ) <repetition> concat >quotation ;
31 : saver ( n -- quot ) \ >r <repetition> >quotation ;
33 : restorer ( n -- quot ) \ r> <repetition> >quotation ;