Lisp HUG Maillist Archive

declarations and safety, whishlist

Hi,

I would like to be able to set a compiler switch and then use type 
declarations ("(declare.." and "(the ..") and trust that erroneous types 
cause errors to be signaled.

Some testing indicates that this is not always the case as of version 4.2, 
with Safety = 3 (and Speed = 0, Space = 0, Float = 1, Interruptible = 0, 
Compilation speed = 1, Debug = 3, Fixnum safety = 3, GC safety = 3).

There appears to be some differences wrt. 'declare' and 'the':

(defun test1 (x)
   (the fixnum (+ x 1)))

CL-USER 58 > (test1 most-positive-fixnum)

Error: The value 8388608 does not satisfy the type specifier FIXNUM.

... which is just what I want, but with 'declare' the situation is different:

(defun test2 (x)
   (declare (fixnum x))
   (+ x x))

CL-USER 62 > (test2 3.3)

Error: System error 30 in function TYPE-OF applied to #<pumpkin, tag 0 
40C12D38>:
        Cannot take this type of object.

CL-USER 66 > (test2 (1+ most-positive-fixnum))
#<character 40BFC9>

CL-USER 67 > (test2 (1+ most-positive-fixnum))
#<pumpkin, tag 0 40BE31A8>

So one more wish for your list would be some kind of "super safety" switch 
that would compile 'the' and 'declare' into check-type (or something similar).



Updated at: 2020-12-10 09:02 UTC