Obj is a newly created and initialized object. Descriptor is a term describing the object to create. After memory is allocated and any slot initializations are performed, a create message is sent to the object.
The functor of Descriptor indicates the class to create. The arguments of the create message are the arguments of Descriptor.
You must have a
method for every
arity N you want to be able to use in creating instances of a
class. This includes arity 0. If no such method exists, a domain
error will be raised.
Given the class definition
:- class point = [public x:integer=1, public y:integer=2]. Self <- create. Self <- create(X, Y) :- Self << x(X), Self << y(Y). :- end_class point.
| ?- create(point, Point1).
point object, with the default slot values for
Point1 to the new object. The command
| ?- create(point(10,15), Point2).
point object with values 10 and 15 for slots
respectively, and binds variable
Point2 to the new object.