factor/extra/singleton/singleton.factor

24 lines
674 B
Factor
Raw Normal View History

! Copyright (C) 2008 Doug Coleman.
2008-03-05 22:35:08 -05:00
! See http://factorcode.org/license.txt for BSD license.
USING: classes.predicate kernel namespaces parser quotations
2008-04-01 17:46:22 -04:00
sequences words prettyprint prettyprint.backend prettyprint.sections
compiler.units classes ;
USE: tools.walker
2008-03-05 22:35:08 -05:00
IN: singleton
2008-04-01 17:46:22 -04:00
PREDICATE: singleton < predicate-class
[ "predicate-definition" word-prop ]
[ [ eq? ] curry ] bi sequence= ;
: define-singleton ( token -- )
2008-03-26 19:23:19 -04:00
create-class-in
2008-04-01 17:46:22 -04:00
dup save-location
\ singleton
2008-03-26 19:23:19 -04:00
over [ eq? ] curry define-predicate-class ;
2008-03-05 22:35:08 -05:00
: SINGLETON:
scan define-singleton ; parsing
2008-04-01 17:46:22 -04:00
M: singleton see-class* ( class -- )
<colon \ SINGLETON: pprint-word pprint-word ;