Rename predicate-word to create-predicate-word and add a new predicate-word word

release
Slava Pestov 2010-01-21 08:00:36 +13:00
parent bd479db2f8
commit 4f68808a72
2 changed files with 8 additions and 6 deletions

View File

@ -37,9 +37,12 @@ PREDICATE: class < word "class" word-prop ;
: classes ( -- seq ) implementors-map get keys ;
: predicate-word ( word -- predicate )
: create-predicate-word ( word -- predicate )
[ name>> "?" append ] [ vocabulary>> ] bi create ;
: predicate-word ( word -- predicate )
"predicate" word-prop first ;
PREDICATE: predicate < word "predicating" word-prop >boolean ;
M: predicate forget*
@ -49,8 +52,7 @@ M: predicate reset-word
[ call-next-method ] [ f "predicating" set-word-prop ] bi ;
: define-predicate ( class quot -- )
[ "predicate" word-prop first ] dip
(( object -- ? )) define-declared ;
[ predicate-word ] dip (( object -- ? )) define-declared ;
: superclass ( class -- super )
#! Output f for non-classes to work with algebra code
@ -144,7 +146,7 @@ M: sequence implementors [ implementors ] gather ;
[ ]
} cleave
] dip [ assoc-union ] curry change-props
dup predicate-word
dup create-predicate-word
[ 1quotation "predicate" set-word-prop ]
[ swap "predicating" set-word-prop ]
[ drop t "class" set-word-prop ]

View File

@ -1,4 +1,4 @@
! Copyright (C) 2008 Slava Pestov.
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: parser vocabs.parser words kernel classes compiler.units lexer ;
IN: classes.parser
@ -9,7 +9,7 @@ IN: classes.parser
: create-class-in ( string -- word )
current-vocab create
dup save-class-location
dup predicate-word dup set-word save-location ;
dup create-predicate-word dup set-word save-location ;
: CREATE-CLASS ( -- word )
scan create-class-in ;