3 ms·
You're right. The standard leaves the interpretation of type declarations in CL up to the implementation. I was coming from a CCL perspective, and I should have
by dreamcompiler 9y ago
You're right. The standard leaves the interpretation of type declarations in CL up to the implementation. I was coming from a CCL perspective, and I should have checked the others.
In CCL:
? (defun foo (a) (declare (type (integer 0 100) a)) (+ a 10))
FOO
? (foo -1)
9
It's dangerous to assume the effect type declarations will have in CL. You have to test it.
- lispm 9y agoEven in CCL it depends on the compiler settings: ? (declaim (optimize (safety 3))) NIL ? (defun foo (a) (declare (type (integer 0 100) a)) (+ a 10)) FOO ? (foo "bar") > Error: The value "bar" is not of the expected type (MOD 101). > While executing: FOO, in process listener(1). > Type :POP to abort, :R for a list of available restarts. > Type :? for other options. 1 > Type declaration added -> runtime safety increased... Best read the implementation manual to see how it deals with optimization values and type declarations.