2005-01-13 14:41:08 -05:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
2005-02-18 20:37:01 -05:00
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-01-13 14:41:08 -05:00
|
|
|
|
|
|
|
IN: generic
|
2005-02-18 20:37:01 -05:00
|
|
|
USING: errors hashtables kernel lists math parser strings
|
|
|
|
vectors words ;
|
2005-01-13 14:41:08 -05:00
|
|
|
|
|
|
|
! Complement metaclass, contains all objects not in a certain class.
|
|
|
|
SYMBOL: complement
|
|
|
|
|
|
|
|
complement [
|
|
|
|
"complement" word-property builtin-supertypes
|
|
|
|
num-types count
|
|
|
|
difference
|
|
|
|
] "builtin-supertypes" set-word-property
|
|
|
|
|
|
|
|
complement [
|
|
|
|
( generic vtable definition class -- )
|
2005-01-23 16:47:28 -05:00
|
|
|
drop num-types [
|
|
|
|
[
|
|
|
|
>r 3dup r> builtin-type
|
|
|
|
dup [ add-method ] [ 2drop 2drop ] ifte
|
|
|
|
] keep
|
|
|
|
] repeat 3drop
|
2005-01-13 14:41:08 -05:00
|
|
|
] "add-method" set-word-property
|
|
|
|
|
|
|
|
complement 90 "priority" set-word-property
|
|
|
|
|
|
|
|
complement [
|
|
|
|
swap "complement" word-property
|
|
|
|
swap "complement" word-property
|
|
|
|
class< not
|
|
|
|
] "class<" set-word-property
|
|
|
|
|
|
|
|
: complement-predicate ( complement -- list )
|
|
|
|
"predicate" word-property [ not ] append ;
|
|
|
|
|
2005-02-21 21:26:20 -05:00
|
|
|
: define-complement ( class complement -- )
|
|
|
|
2dup "complement" set-word-property
|
|
|
|
dupd complement-predicate "predicate" set-word-property
|
2005-01-13 14:41:08 -05:00
|
|
|
complement define-class ;
|