file: job.t package: muf status: alpha
As the name suggests, ]defclass
defines a
class. A typical sample use is:
Stack: [ 'ship 'x 'y 'mass | ]defclass
which accomplishes the following:
ship
structure type with three components,
x
, y
and mass
.
ship
becomes the name of this structure type.
ship?
which is true of (only)
instances of this structure type.
]make-ship
which constructs
instances of this type: [ :x 0.5 :y 2.0 :mass 15.0 | ]make-ship --> s
The full syntax follows the CommonLisp standard fairly closely, and (hence?) is fairly intimidating. Using the notation (* x | y *) to indicate a sequence of zero or more x and/or y instances:
'aClassName (* :isA 'anotherClassName | :is 'anotherClassName | :has 'anotherClassName | :hasA 'anotherClassName | :metaclass 'metaclassName | :documentation "some text" | :fertile tOrNil | :abstract tOrNil | :export tOrNil *) (* :slot :my-slot (* | :initval any | :initform cfn | :initarg 'aName | :type type | :reader 'readerFnName | :writer 'writerFnName | :accessor 'accessorFnName | :allocation :class | :allocation :instance | :documentation "some text" | :rootMayRead tOrNil | :rootMayWrite tOrNil | :userMayRead tOrNil | :userMayWrite tOrNil | :classMayRead tOrNil | :classMayWrite tOrNil | :worldMayRead tOrNil | :worldMayWrite tOrNil | :prot "rw----" *) *)
The first group of options apply to the class proper; The last group of options apply to a particular slot.
Structure options:
:metaclass symbol
:isA symbol
:is
, :has
and :hasA
are also
supported, simply because they sometimes let code
read more naturally.)
:documentation string
:initarg symbol value
The next section declares those slots which are not inherited, together with optional slot options declaring individual properties for each slot.
Slot options:
:initform any
:initarg 'symbol
initializeInstance
.
MOS allows multiple :initarg
values
per slot, Muq currently allows only one.
:type type
:documentation "some text"
:allocation { :class | :instance }
:allocation
of :class
results in the slot instead
being allocated in the class itself, containing
a single value shared between all instances.
:reader 'symbol
:reader
options per slot, Muq currently
allows only one.
:writer 'symbol
:writer
options per slot, Muq currently
allows only one.
:accessor 'xxx
setf-xxx
will also be defined. MOS allows
multiple :accessor
options per slot, Muq
currently allows only one.
:rootMayRead tOrNil
:rootMayWrite tOrNil
:userMayRead tOrNil
]make-foo
creating the
structure containing the slot.
:userMayWrite tOrNil
]make-foo
creating the
structure containing the slot.
:classMayRead tOrNil
:classMayWrite tOrNil
:worldMayRead tOrNil
:worldMayWrite tOrNil
:prot "rw----"
Go to the first, previous, next, last section, table of contents.