[armedbear-devel] SLOT-VALUE and SLOT-VALUE-USING-CLASS with DEFSTRUCT

Alessio Stalla alessiostalla at gmail.com
Fri Jun 18 07:07:32 UTC 2010


On Fri, Jun 18, 2010 at 6:41 AM, Tobias C Rittweiler <tcr at freebits.de> wrote:
>
>> I committed (r12756) a simple implementation of SLOT-VALUE and friends
>> (setf slot-value, slot-boundp, slot-makunbound) for structures. It
>> searches for slots by iterating through the list of slot names stored
>> in the structure-class, which is probably not very good
>> performance-wise (CLOS objects use a map). Structure slots are
>> initialized to NIL and can't be unbound, and
>> slot-boundp/slot-makunbound reflect this.
>>
>> I also added the necessary autoloads to autoloads.lisp.
>>
>> Bye,
>> Alessio
>
> Regarding the initialization, this is not quite true; CLHS
> defstruct says
>
>  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. 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.
>
> As consequences are undefined, always returning NIL is compliant,
> but you could also make it signal an error, and make SLOT-BOUNDP
> cover this case.

Oh, thanks for pointing this out! I must admit I didn't check the CLHS
but simply tried slot-makunbound on sbcl (which gives an error). Since
I believe there's no such restriction in abcl, I could make it work
like in classes.

Bye,
Alessio




More information about the armedbear-devel mailing list