69 lines · 2.5 KB · Text
RawDownload
(doc-group struct  «Declaring and manipulating structures.») (defdoc (defstruct name                    docs…                    options…                    (slot-1 DEFAULT)                    slot-2                    slot-3)) ',sym ',doc ',callvars (defdoc (defstruct name (:type vec)                        (:named T named-supplied)                        (:constructor T constructor-supplied)                        (:conc-name T conc-name-supplied)                        (:predicate T predicate-supplied)                        . slots)  «Declare a new structure type with the specified name and slots.    The default underlying type is a "named" vector (`:type vec`), where   the first element is the name of the structure's type, the rest are   the keyworded slot values.  A list with slot values alone can be used   instead by adding `:type list` option.  The list will not contain the   name of the struct by default, which can be enabled with `:named T`   option.    As an example, the following declaration generates the default   constructor for a structure of three slots, with one of them (`c`)   having a non-`NIL` default value and marked as read-only:        (defstruct blah "Return stuff." :doc-group stuff a b (c 1 :read-only T))       ; (make-blah (:a NIL) (:b NIL) (:c 1))       ; (blah-a s)       ; (blah-b s)       ; (blah-c s)       ; (blah-a! s new-a)       ; (blah-b! s new-b)    Slot's options, if any, should be specified after its default value.   Supported options are:        ; mark the slot as read-only       ; its value can be read, but trying to modify it will throw an error       … :read-only T    The constructor can be changed in several ways:        ; disable the constructor altogether       (defstruct blah :constructor NIL a b c)       ; only change its name       (defstruct blah :constructor blargh a b c)       ; rename AND avoid using keywords       (defstruct blah :constructor (blah a b c) a b c)    The option `:conc-name` specifies the slot accessor/setter prefix,   which defaults to `structname-`.  Prefix can be disabled entirely with   `:conc-name NIL`.    Slot setters are generated for writable slots by appending `!`   (exclamation mark) to the accessor's name.    Default predicate can be disabled or its name, which defaults to   `structname?`, changed:        ; use "blargh?" instead of "blah?"       (defstruct blah :predicate blargh? a b c)       ; without predicate       (defstruct blah :predicate NIL a b c)»  :doc-group struct)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t