[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are several ways to access slot values in an object. The naming convention and argument order is similar to that found in Emacs Lisp for referencing vectors. The basics for referencing, setting, and calling methods are all accounted for.
This sets the value behind slot to value in object.
oset
returns value.
This sets the slot slot in class which is initialized with
the :initform
tag to value. This will allow a user to set
both public and private defaults after the class has been constructed.
This function is intrusive, and is offered as a way to allow users to
configure the default behavior of packages built with classes the same
way setq-default
is used for buffer-local variables.
For example, if a user wanted all data-objects
(see section 3. Building Classes) to inform a special object of his own devising when they
changed, this can be arranged by simply executing this bit of code:
(oset-default data-object reference (list my-special-object)) |
This recalls the value in slot slot in object and returns it. If object is a class, and slot is a class allocated slot, then oref will return that value. If object is a class, and slot is not class allocated, a signal will be thrown.
slot
. This can be different from the value returned by
oref
. object can also be a class symbol or an instantiated
object.
These next accessors are defined by CLOS to reference or modify slot values, and use the previously mentioned set/ref routines.
oref
, the symbol for slot must be quoted in.
slot-value
if
you don't want to use the cl package's setf
function. This
function sets the value of slot from object. Unlike
oset
, the symbol for slot must be quoted in.
setf
to assign to these values, but
in Emacs, you may only read the values, or set the local variable to a
new value.
(defclass myclass () (x :initarg 1)) (setq mc (make-instance 'myclass)) (with-slots (x) mc x) => 1 (with-slots ((something x)) mc something) => 1 |
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.