diff options
| author | Daniel Colascione | 2014-04-19 19:34:22 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2014-04-19 19:34:22 -0700 |
| commit | 89a2e783c2f22b4932dd77c16a0e357c5c17a4bf (patch) | |
| tree | e3cdb05ac00ce099145ac0205c6ce12da43e7f1d /doc/misc | |
| parent | 6dfa19c50f75c1892f5c9a48104ddd532796d089 (diff) | |
| download | emacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.tar.gz emacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.zip | |
defstruct introspection
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/cl.texi | 40 |
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. | |||
| 4247 | Except as noted, the @code{cl-defstruct} facility of this package is | 4247 | Except as noted, the @code{cl-defstruct} facility of this package is |
| 4248 | entirely compatible with that of Common Lisp. | 4248 | entirely compatible with that of Common Lisp. |
| 4249 | 4249 | ||
| 4250 | The @code{cl-defstruct} package also provides a few structure | ||
| 4251 | introspection functions. | ||
| 4252 | |||
| 4253 | @defun cl-struct-sequence-type struct-type | ||
| 4254 | This 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 | ||
| 4257 | structure. | ||
| 4258 | |||
| 4259 | @defun cl-struct-slot-info struct-type | ||
| 4260 | This function returns a list of slot descriptors for structure | ||
| 4261 | @code{struct-type}. Each entry in the list is @code{(name . opts)}, | ||
| 4262 | where @code{name} is the name of the slot and @code{opts} is the list | ||
| 4263 | of slot options given to @code{defstruct}. Dummy entries represent | ||
| 4264 | the 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 | ||
| 4268 | Return the offset of slot @code{slot-name} in @code{struct-type}. The | ||
| 4269 | returned zero-based slot index is relative to the start of the | ||
| 4270 | structure data type and is adjusted for any structure name and | ||
| 4271 | :initial-offset slots. Signal error if struct @code{struct-type} does | ||
| 4272 | not contain @code{slot-name}. | ||
| 4273 | |||
| 4274 | @defun cl-struct-slot-value struct-type slot-name inst | ||
| 4275 | Return 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 | ||
| 4280 | errors. | ||
| 4281 | |||
| 4282 | @defun cl-struct-set-slot-value struct-type slot-name inst value | ||
| 4283 | Set 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 | ||
| 4286 | which to set the given slot. Return @code{value}. | ||
| 4287 | @code{cl-struct-slot-value} uses @code{cl-struct-set-slot-offset} | ||
| 4288 | internally 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 | ||