[ 10 ] [ -10 abs ] unit-test
[ 10 ] [ 10 abs ] unit-test
-[ 0 ] [ 0 abs ] unit-test
-
-PREDICATE: blah < word blah eq? ;
-
-[ f ] [ \ predicate-instance? "compiled-uses" word-prop keys \ blah swap memq? ] unit-test
-
-FORGET: blah
\ No newline at end of file
+[ 0 ] [ 0 abs ] unit-test
\ No newline at end of file
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: classes classes.algebra kernel namespaces make words
sequences quotations arrays kernel.private assocs combinators ;
PREDICATE: predicate-class < class
"metaclass" word-prop predicate-class eq? ;
-DEFER: predicate-instance? ( object class -- ? )
-
-: update-predicate-instance ( -- )
- \ predicate-instance? bootstrap-word
- classes [ predicate-class? ] filter [
- [ literalize ]
- [
- [ superclass 1array [ declare ] curry ]
- [ "predicate-definition" word-prop ]
- bi compose
- ]
- bi
- ] { } map>assoc [ case ] curry
- define ;
-
: predicate-quot ( class -- quot )
[
\ dup ,
[ dup predicate-quot define-predicate ]
[ update-classes ]
bi
- ]
- 3tri
- update-predicate-instance ;
+ ] 3tri ;
M: predicate-class reset-class
- [ call-next-method ] [ { "predicate-definition" } reset-props ] bi
- update-predicate-instance ;
+ [ call-next-method ] [ { "predicate-definition" } reset-props ] bi ;
M: predicate-class rank-class drop 1 ;
M: predicate-class instance?
- 2dup superclass instance?
- [ predicate-instance? ] [ 2drop f ] if ;
+ 2dup superclass instance? [
+ "predicate-definition" word-prop call( object -- ? )
+ ] [ 2drop f ] if ;
M: predicate-class (flatten-class)
superclass (flatten-class) ;