Anton Samoylov <toshaevil@...> writes:
> (defclass myclass () ((myslot :type string :initarg :myslot :accessor
> (make-instance 'myclass :myslot 1)
> Code above produce no error, but 1 ins't of type string.
> Tested on sbcl 1.0.55 and 1.0.57
With default safety SBCL doesn't perform type checking for CLOS
slots. CLOS is quite dynamic and it's hard to employ any optimization
and do efficient type checking.
(defun foo ()
(declare (optimize safety))
(make-instance 'myclass :myslot 1))
will signal an error.
If you're trying to declare types in an attempt to make code faster,
then you should either not declare any types, or use structures instead.
With best regards, Stas.