factor/core/classes/singleton/singleton.factor

20 lines
614 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 ;
2008-04-01 17:51:48 -04:00
IN: classes.singleton
2008-03-05 22:35:08 -05:00
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-04-01 17:46:22 -04:00
M: singleton see-class* ( class -- )
<colon \ SINGLETON: pprint-word pprint-word ;