]> gitweb.factorcode.org Git - factor.git/blob - core/words/constant/constant.factor
b518760bf980ded0d0fb3c6c8186c35f161a3c98
[factor.git] / core / words / constant / constant.factor
1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel sequences words definitions quotations ;
4 IN: words.constant
5
6 PREDICATE: constant < word "constant" word-prop >boolean ;
7
8 : define-constant ( word value -- )
9     [ "constant" set-word-prop ]
10     [ [ ] curry (( -- value )) define-inline ] 2bi ;
11
12 M: constant reset-word
13     [ call-next-method ] [ f "constant" set-word-prop ] bi ;
14
15 M: constant definer drop \ CONSTANT: f ;
16
17 M: constant definition "constant" word-prop literalize 1quotation ;