From bdec3951307141084479dc2596b430d775f89f33 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 16 Mar 2009 20:49:19 -0500 Subject: [PATCH] Remove predicate-instance? hack; use call( instead --- core/bootstrap/primitives.factor | 3 -- core/classes/predicate/predicate-tests.factor | 8 +---- core/classes/predicate/predicate.factor | 29 ++++--------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 5ad693bc86..48aae3667e 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -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 diff --git a/core/classes/predicate/predicate-tests.factor b/core/classes/predicate/predicate-tests.factor index d4c929a69b..a947b9ddc0 100644 --- a/core/classes/predicate/predicate-tests.factor +++ b/core/classes/predicate/predicate-tests.factor @@ -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 diff --git a/core/classes/predicate/predicate.factor b/core/classes/predicate/predicate.factor index 7d757772f4..188a2ed794 100644 --- a/core/classes/predicate/predicate.factor +++ b/core/classes/predicate/predicate.factor @@ -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) ;