factor/core/classes/singleton/singleton.factor

18 lines
542 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.
2008-07-12 02:08:30 -04:00
USING: classes classes.algebra classes.predicate kernel
sequences words ;
2008-04-01 17:51:48 -04:00
IN: classes.singleton
2008-03-05 22:35:08 -05:00
2008-04-02 16:41:29 -04:00
PREDICATE: singleton-class < predicate-class
2008-04-01 17:46:22 -04:00
[ "predicate-definition" word-prop ]
[ [ eq? ] curry ] bi sequence= ;
2008-04-02 16:41:29 -04:00
: define-singleton-class ( word -- )
\ word over [ eq? ] curry define-predicate-class ;
M: singleton-class instance? eq? ;
2008-07-12 02:08:30 -04:00
M: singleton-class (classes-intersect?)
over singleton-class? [ eq? ] [ call-next-method ] if ;