Classes
Factor handbook » The language » Objects

Prev:Linear order protocol
Next:Tuples


Conceptually, a class is a set of objects whose members can be identified with a predicate, and on which generic words can specialize methods. Classes are organized into a general partial order, and an object may be an instance of more than one class.

At the implementation level, a class is a word with certain word properties set.

Words for working with classes are found in the classes vocabulary.

Classes themselves form a class:
class? ( object -- ? )


You can ask an object for its class:
class-of ( object -- class )


Testing if an object is an instance of a class:
instance? ( object class -- ? )


You can ask a class for its superclass:
superclass-of ( class -- super )

superclasses-of ( class -- supers )

subclass-of? ( class superclass -- ? )


Class predicates can be used to test instances directly:
Class predicate words

There is a universal class which all objects are an instance of, and an empty class with no instances:
object

null


Obtaining a list of all defined classes:
classes ( -- seq )


There are several sorts of classes:
Built-in classes
Union classes
Intersection classes
Maybe classes
Mixin classes
Predicate classes
Singleton classes

Tuples are documented in their own section.

Classes can be inspected and operated upon:
Class operations
Class linearization

See also
Class index