]> gitweb.factorcode.org Git - factor.git/commitdiff
Remove predicate-instance? hack; use call( instead
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 17 Mar 2009 01:49:19 +0000 (20:49 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 17 Mar 2009 01:49:19 +0000 (20:49 -0500)
core/bootstrap/primitives.factor
core/classes/predicate/predicate-tests.factor
core/classes/predicate/predicate.factor

index 5ad693bc86a3bd59472952b127d41ada5ca1fdba..48aae3667e29eaf4a77d1383c15e7da91da706e4 100644 (file)
@@ -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
 
index d4c929a69bfe4724dcab6b02ba53c6de94f9ab07..a947b9ddc09af419925ab52d60e65a979fdda998 100644 (file)
@@ -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
\ No newline at end of file
+[ 0 ] [ 0 abs ] unit-test
\ No newline at end of file
index 7d757772f40055dfe5693243f8b9660d4602eaf9..188a2ed794b6e88b3f9455420d4fcec978b96c53 100644 (file)
@@ -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) ;