Using :type slot option
"Bruno Emond (as emond dot bruno at gmail dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
I understand that the Common Lisp standard specifies that "The consequences of attempting to store in a slot a value that does not satisfy the type of the slot are undefined.”. However, I am wondering if there is a simpler way to implement slot type checking than the code I wrote (see file attached). A small annoyance with this code is that one need to always include: 1) inheritance to a class that verify slot types when an instance is initialized (however this can be done once for the most general class), 2) the metaclass option to verify a slot type when the slot value is set, and possibly (has to be done for every class definition), 3) the class option :optimize-slot-access nil (has to be done for every class definition), if one also wants to verify the type of a slot when it is set using an accessor. Thanks for any suggestions. Bruno
typep-slots.lisp
(application/octet-stream, 3.1 KB) - not displayed