SBCL is a strange Lisp implementation, since it does some compile-time type checks, too.
* (defun id (f) f)
ID
* (declaim (ftype (function (fixnum) fixnum) id))
(ID)
Our new identity function is declared to be of type fixnum -> fixnum.
* (declaim (optimize (safety 0)))
NIL
Now we've set safety to 0.
Let's define a function which calls ID with a string
* (defun use-id (s) (declare (type string s)) (id s))
; in: DEFUN USE-ID
; (ID S)
;
; caught WARNING:
; Derived type of S is
; (VALUES STRING &OPTIONAL),
; conflicting with its asserted type
; FIXNUM.
; See also:
; The SBCL Manual, Node "Handling of Types"
;
; compilation unit finished
; caught 1 WARNING condition
USE-ID
Even though safety is 0, the compiler warned us about a compile-time type problem.
Let's define a function which calls ID with a string
Even though safety is 0, the compiler warned us about a compile-time type problem.