[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sbcl-help
Subject:    Re: [Sbcl-help] No type check in for slots in class
From:       Stas Boukarev <stassats () gmail ! com>
Date:       2012-05-31 12:48:45
Message-ID: 87k3zszfbm.fsf () gmail ! com
[Download RAW message or body]

Anton Samoylov <toshaevil@gmail.com> writes:

> (defclass myclass () ((myslot :type string :initarg :myslot :accessor
> myslot)))
> (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.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Sbcl-help mailing list
Sbcl-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic