PREDICATE:
Factor handbook > The language > Objects > Classes > Predicate classes

Next:define-predicate-class ( class superclass definition -- )


Vocabulary
syntax

Syntax
PREDICATE: class < superclass predicate... ;


Inputs and outputs
classa new class word to define
superclassan existing class word
predicatemembership test with stack effect ( superclass -- ? )


Word description
Defines a predicate class deriving from superclass.

An object is an instance of a predicate class if two conditions hold:
it is an instance of the predicate's superclass,
it satisfies the predicate

Each predicate must be defined as a subclass of some other class. This ensures that predicates inheriting from disjoint classes do not need to be exhaustively tested during method dispatch.

Examples
USING: math ; PREDICATE: positive < integer 0 > ;


See also
predicate-class, define-predicate-class

Definition