Hi !

I'm continuing my experiments with slot type checking, on structures
this time. Consider this:

(defstruct mystruct (slot "foo" :type single-float))

Regardless of the optimize settings, I will get an error every time I
try to create a mystruct object; so it seems that CMU-CL performs
structure slot type checking all the time.

However, in the following case:

(defstruct mystruct (slot "foo" :type fixnum))

I *never* get an error. I find this a bit inconsistent. Here's a wild
guess that might explain this behavior: if it goes like in SBCL, fixnums
are represented in structs in raw form, with their tag, so the
consequence is that there is no need for any type checking[1] to
guarantee that the slot can be accessed (read and written) properly,
even with something else than a fixnum.

That would be different with single-float's if they use a specialized
representation in structs, in which case you have to be more cautious
when accessing the slot.

Comments ?



Footnotes: 
[1]  appart from honoring the user's type declaration of course

-- 
Resistance is futile. You will be jazzimilated.

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com

EPITA/LRDE, 14-16 rue Voltaire, 94276 Le Kremlin-BicĂȘtre, France
Tel. +33 (0)1 44 08 01 85       Fax. +33 (0)1 53 14 59 22

Reply via email to