Function: defstruct

defstruct is a for cl-defstruct, defined in cl-macs.el.gz.

This macro is obsolete since 27.1; use cl-defstruct instead.

Signature

(defstruct NAME &optional DOCSTRING &rest SLOTS)

Documentation

Define a struct type.

This macro defines a new data type called NAME that stores data in SLOTs. It defines a make-NAME constructor, a copy-NAME copier, a NAME-p predicate, and slot accessors named NAME-SLOT. You can use the accessors to set the corresponding slots, via setf.

NAME is usually a symbol, but may instead take the form (NAME OPTIONS...), where each OPTION is either a single keyword or (KEYWORD VALUE) where KEYWORD can be one of :conc-name,
:constructor, :copier, :predicate, :type, :named,
:initial-offset, :print-function, :noinline, or :include.
See Info node (cl)Structures for the description of the options.

The first element in SLOTS can be a doc string.

The rest of the elements in SLOTS is a list of SLOT elements, each of which should either be a symbol, or take the form (SNAME SDEFAULT SOPTIONS...), where SDEFAULT is the default value of that slot and SOPTIONS are keyword-value pairs for that slot.

Supported keywords for slots are:
- :read-only: If this has a non-nil value, that slot cannot be set via setf.
- :documentation: this is a docstring describing the slot.
- :type: the type of the field; currently only used for documentation.

To see the documentation for a defined struct type, use C-h o (describe-symbol) or M-x cl-describe-type (cl-describe-type).

Probably introduced at or before Emacs version 21.1.

Aliases

defstruct (obsolete since 27.1)