Next: Class Options, Previous: Inheritance, Up: Building Classes
The slot-list argument to defclass is a list of elements
where each element defines one slot. Each slot is a list of the form
(SLOT-NAME :TAG1 ATTRIB-VALUE1
:TAG2 ATTRIB-VALUE2
:TAGN ATTRIB-VALUEN)
where SLOT-NAME is a symbol that will be used to refer to the slot. :TAG is a symbol that describes a feature to be set on the slot. ATTRIB-VALUE is a lisp expression that will be used for :TAG.
Valid tags are:
:initargA good symbol to use for initarg is one that starts with a colon :.
The slot specified like this:
(myslot :initarg :myslot)
could then be initialized to the number 1 like this:
(myobject "name" :myslot 1)
See Making New Objects.
:initformIf :initform is left out, that slot defaults to being unbound.
It is an error to reference an unbound slot, so if you need
slots to always be in a bound state, you should always use an
:initform specifier.
Use slot-boundp to test if a slot is unbound
(see Predicates). Use slot-makeunbound to set a slot to
being unbound after giving it a value (see Accessing Slots).
The value passed to initform is automatically quoted. Thus,
:initform (1 2 3)
appears as the specified list in the default object. A symbol that is a function like this:
:initform +
will set the initial value as that symbol.
After a class has been created with defclass, you can change
that default value with oset-default. Accessing Slots.
:typesymbolnumbermy-class-name(or null symbol):allocation:documentation:accessorThis options is in the CLOS spec, but is not fully compliant in EIEIO.
:writerThis options is in the CLOS spec, but is not fully compliant in EIEIO.
:readerThis options is in the CLOS spec, but is not fully compliant in EIEIO.
:customdefcustom for details. This specifier is
equivalent to the :type spec of a defcustom call.
This options is specific to Emacs, and is not in the CLOS spec.
:labelThis options is specific to Emacs, and is not in the CLOS spec.
:groupdefcustom's :group command, this organizes different
slots in an object into groups. When customizing an object, only the
slots belonging to a specific group need be worked with, simplifying the
size of the display.
This options is specific to Emacs, and is not in the CLOS spec.
:printerobject-write will write the
slot value out to a printable form on standard-output.
The output format MUST be something that could in turn be interpreted
with read such that the object can be brought back in from the
output stream. Thus, if you wanted to output a symbol, you would need
to quote the symbol. If you wanted to run a function on load, you
can output the code to do the construction of the value.
:protectionslot-value, and
the value behind slot is private or protected, then the current
scope of operation must be within a method of the calling object.
Valid values are:
:public:protected:privateThis options is specific to Emacs, and is not in the CLOS spec.