Remove predicate-instance? hack; use call( instead
parent
ead3452957
commit
bdec395130
|
@ -140,9 +140,6 @@ bootstrapping? on
|
|||
"word" "words" create register-builtin
|
||||
"byte-array" "byte-arrays" create register-builtin
|
||||
|
||||
! For predicate classes
|
||||
"predicate-instance?" "classes.predicate" create drop
|
||||
|
||||
! We need this before defining c-ptr below
|
||||
"f" "syntax" lookup { } define-builtin
|
||||
|
||||
|
|
|
@ -18,10 +18,4 @@ M: positive abs ;
|
|||
|
||||
[ 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
|
||||
[ 0 ] [ 0 abs ] unit-test
|
|
@ -1,4 +1,4 @@
|
|||
! 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 ;
|
||||
|
@ -7,21 +7,6 @@ IN: classes.predicate
|
|||
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 ,
|
||||
|
@ -38,19 +23,17 @@ DEFER: predicate-instance? ( object class -- ? )
|
|||
[ 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) ;
|
||||
|
|
Loading…
Reference in New Issue