Consider a structure defined like this:
(defstruct mystruct (slot 1 :type fixnum))
I've noticed that calls to (make-struct) perform faster with optimized
code (optimize 3) (<rest> 0) than with safe code (safety 3) (<rest 0).
This seems coherent with the fact that in in safe mode, a bogus initval
(like 1.5) would be caught and trigger an error, something that does not
happen in the optimized case.
What was surprising to me on the other hand, was that something like:
(defstruct mystruct (slot 1.5 :type fixnum))
works "smoothly" in the optimized case, meaning that I don't get
nonsense by calling mystruct-slot1, but an actual float value of 1.5. So
I though maybe that's because structure slots are actually just lisp
objects, and don't benefit from any particular optimization in their
But this doesn't seem to hold either. Because, consider this (optimized
CL-UCL-USER> (defstruct foo (slot 1.45 :type single-float))
#S(FOO2 :SLOT 1.45)
CL-USER> (make-foo :slot "bar")
#S(FOO2 :SLOT 1.6815582e-44)
CL-USER> (make-foo :slot 1)
; Evaluation aborted.
So how is it that with a slot type of fixnum, things still work, even if
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