aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorDaniel Colascione2014-04-19 19:34:22 -0700
committerDaniel Colascione2014-04-19 19:34:22 -0700
commit89a2e783c2f22b4932dd77c16a0e357c5c17a4bf (patch)
treee3cdb05ac00ce099145ac0205c6ce12da43e7f1d /doc/misc
parent6dfa19c50f75c1892f5c9a48104ddd532796d089 (diff)
downloademacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.tar.gz
emacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.zip
defstruct introspection
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/cl.texi40
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index f0ac289acab..1c202961889 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -4247,6 +4247,46 @@ of the included type and the first new slot.
4247Except as noted, the @code{cl-defstruct} facility of this package is 4247Except as noted, the @code{cl-defstruct} facility of this package is
4248entirely compatible with that of Common Lisp. 4248entirely compatible with that of Common Lisp.
4249 4249
4250The @code{cl-defstruct} package also provides a few structure
4251introspection functions.
4252
4253@defun cl-struct-sequence-type struct-type
4254This function returns the underlying data structure for
4255@code{struct-type}, which is a symbol. It returns @code{vector} or
4256@code{list}, or @code{nil} if @code{struct-type} is not actually a
4257structure.
4258
4259@defun cl-struct-slot-info struct-type
4260This function returns a list of slot descriptors for structure
4261@code{struct-type}. Each entry in the list is @code{(name . opts)},
4262where @code{name} is the name of the slot and @code{opts} is the list
4263of slot options given to @code{defstruct}. Dummy entries represent
4264the slots used for the struct name and that are skipped to implement
4265@code{:initial-offset}.
4266
4267@defun cl-struct-slot-offset struct-type slot-name
4268Return the offset of slot @code{slot-name} in @code{struct-type}. The
4269returned zero-based slot index is relative to the start of the
4270structure data type and is adjusted for any structure name and
4271:initial-offset slots. Signal error if struct @code{struct-type} does
4272not contain @code{slot-name}.
4273
4274@defun cl-struct-slot-value struct-type slot-name inst
4275Return the value of slot @code{slot-name} in @code{inst} of
4276@code{struct-type}. @code{struct} and @code{slot-name} are symbols.
4277@code{inst} is a structure instance. This routine is also a
4278@code{setf} place. @code{cl-struct-slot-value} uses
4279@code{cl-struct-slot-offset} internally and can signal the same
4280errors.
4281
4282@defun cl-struct-set-slot-value struct-type slot-name inst value
4283Set the value of slot @code{slot-name} in @code{inst} of
4284@code{struct-type}. @code{struct} and @code{slot-name} are symbols.
4285@code{inst} is a structure instance. @code{value} is the value to
4286which to set the given slot. Return @code{value}.
4287@code{cl-struct-slot-value} uses @code{cl-struct-set-slot-offset}
4288internally and can signal the same errors.
4289
4250@node Assertions 4290@node Assertions
4251@chapter Assertions and Errors 4291@chapter Assertions and Errors
4252 4292