[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A class in EIEIO has a similar structure to that found in other
languages. A new class is created with defclass
This function is specified by CLOS, and EIEIO conforms in structure.
Creates a new class called class-name
. The created variable's
documentation string is set to a modified version of the doc string
found in options-or-doc. Each time a slot is defined the
variables documentation string is updated to include the methods
documentation as well.
The parent class for class-name
is superclass-list which
must be a list. Each element of this list must be a class. These
classes form the parents of the class being created. Every slot in
parent is replicated in the new class. If two parents share the same
slot name, the parent which appears in the list first sets the attributes
for that slot. If a slot in the new class' slot list matches a parent,
then the new specifications for the child class override that of the
parent.
slot-list is a list of lists. Each sublist defines an attribute.
These lists are of the form (name :tag1 value1 :tag2 value2 :tagn
valuen)
. Some valid CLOS tags are:
:initarg
:
.
:initform
:initform (1 2 3) |
:initform + |
Lastly, using the function lambda-default
instead of
lambda
will let you specify a lambda expression to use as the
value, without evaluation.
:type
symbol
number
my-class-name
(or null symbol)
function
lambda-default
expression.
:allocation
:documentation
Some tags whose behaviors do not yet match CLOS are:
:accessor
:writer
:reader
Some tags which are unique to EIEIO are:
:custom
defcustom
for details. This specifier is
equivalent to the :type field of a defcustom
call.
:label
:group
defcustom
'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.
:protection
When using a slot referencing function, if 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
:private
Additionally, CLOS style class options are available. These are various options attached to a class. These options can occur in place or in addition to a documentation string. If both occur, then the options appear before the documentation string. In CLOS, documentation is one of the options available to a class, so the ability to have a standalone documentation string is specific to Emacs.
Possible class options are:
:documentation
:allow-nil-initform
If this option is non-nil, and the :initform
is nil
, but
the :type
is specifies something such as string
then allow
this to pass. The default is to have this option be off. This is
implemented as an alternative to unbound slots.
:abstract
Tags a class as being abstract, or uninstantiable.
:custom-groups
class-option
command,
however, to see what groups are available.
:metaclass
standard-class
.
:default-initargs
:initform
.
See section 2. CLOS compatibility, for more details on CLOS tags versus EIEIO specific tags.
The whole definition may look like this:
(defclass data-object () ((value :initarg :value :initform nil :accessor get-value :documentation "Lisp object which represents the data this object maintains." :protection :protected) (reference :initarg :reference :initform nil :type list :custom (repeat object) :documentation "List of objects looking at this object. The method `update-symbol' is called for each member of `reference' whenever `value' is modified." :protection :protected) ) "Data object which tracks referencers.") |
defclass
will throw an error if a tag
in a slot specifier is unsupported.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.