![]() ![]() This is entirely analogous to the declaration of a variable or function it effectively declares the result type of the reader function. This specifies that the contents of the slot is always of type type. This specifies that each slot always contains a short float, and that the last slot cannot be altered once a ship is constructed. (mass *default-ship-mass* :type short-float :read-only t)) A slot-option consists of a pair of a keyword and a value (which is not a form to be evaluated, but the value itself). The slot default init forms are evaluated in the lexical environment in which the defstruct form itself appears and in the dynamic environment in which the call to the constructor function appears.įor example, if the form (gensym) were used as an initialization form, either in the constructor-function call or as the default initialization form in defstruct, then every call to the constructor function would call gensym once to generate a new symbol.Įach slot-description in defstruct can specify zero or more slot-options. ![]() The symbols which name the slots must not be used by the implementation as the names for the lambda variables in the constructor function, since one or more of those symbols might have been proclaimed special or might be defined as the name of a constant variable. It is as if the slot-initforms were used as initialization forms for the keyword parameters of the constructor function. (defstruct person (name 007 :type string)) For example, in the following sequence, only the last call is an error. If it is never needed, there can be no type-mismatch error, even if the type of the slot is specified no warning should be issued in this case. The slot-initform is not evaluated unless it is needed in the creation of a particular structure instance. If no slot-initform is supplied, the consequences are undefined if an attempt is later made to read the slot's value before a value is explicitly assigned.Įach slot-initform supplied for a defstruct component, when used by the constructor function for an otherwise unsupplied component, is re-evaluated on every call to the constructor function. If a slot is not initialized in this way, it is initialized by evaluating slot-initform in the slot description at the time the constructor function is called. All the keywords and forms are evaluated. Each slot keyword argument must be a keyword whose name corresponds to the name of a structure slot. The arguments to the constructor function are all keyword arguments. A call to a constructor function is of the following form: nil indicates that no constructor function will be created.Īfter a new structure type has been defined, instances of that type normally can be created by using the constructor function for the type. ![]() A different name can be supplied by giving the name as the argument to the constructor option. The default name is make- structure-name. If documentation is supplied, it is attached to structure-name as a documentation string of kind structure, and unless :type is used, the documentation is also attached to structure-name as a documentation string of kind type and as a documentation string to the class object for the class named structure-name.ĭefstruct defines a constructor function that is used to create instances of the structure created by defstruct. All names of automatically created functions might automatically be declared inline (at the discretion of the implementation). Also, unless overridden, it defines a predicate named name -p, defines a constructor function named make- constructor-name, and defines a copier function named copy- constructor-name. Type-one of the type specifiers list, vector, or (vector size ), or some other type specifier defined by the implementation to be appropriate.ĭefstruct defines a structured type, named structure-type, with named slots as specified by the slot-options.ĭefstruct defines readers for the slots and arranges for setf to work properly on such reader functions. Printer-name-a function name or a lambda expression. Note that a derived type is not permissible, even if it would expand into a structure name. ![]() Included-structure-name-an already-defined structure name. Initial-offset-option::= (:initial-offset initial-offset) Print-function-option::= (:print-function printer-name) | (:print-function) Print-object-option::= (:print-object printer-name) | (:print-object) Printer-option::= print-object-option | print-function-option ![]()
0 Comments
Leave a Reply. |