>>>>> "Madhu" == Madhu  <[EMAIL PROTECTED]> writes:

    Madhu> * Raymond Toy <[EMAIL PROTECTED]> :
    Madhu> Wrote on Tue, 02 Dec 2008 20:23:45 -0500:

    Madhu> |> It may also have been a tradeoff, [since it is not being done in 
the
    Madhu> |> compiler] and you want to have at least one path available to the
    Madhu> |> programmer to set a slot value that avoids overhead of a type 
check.
    Madhu> |
    Madhu> | I've implemented this already.  It basically does a check-type for 
(setf
    Madhu> | slot-value) for standard objects.  This doesn't change what 
happens when
    Madhu> | slot-value is used in a method.

    Madhu> I'm not sure this is a good idea.  (But I have not measured the cost 
of
    Madhu> the change, NOTE: I'm not objecting to the change)

I did a quick test with:

(defclass foo2 ()
  ((slot :type single-float :initform 1.2f0)
   (slot2)))

(defclass bar ()
  ((a :type fixnum :initform 0)))

(defparameter *o* (make-instance 'foo2))

(defmethod setslot ((obj bar) val)
  (setf (slot-value *o* 'slot) val)
  (setf (slot-value obj 'a) val))


Compile up the previous code.  Then (setf (slot-value (make-instance
'foo2) 'slot) "string") signals an error.

But (setslot (make-instance 'bar) 99) doesn't signal an error even
though we're assigning a fixnum to a slot of type single-float.
Hence, the change I made doesn't apply to slot-value in methods.  (I
guess slot-value in methods takes a different path.)

I don't know PCL well enough to know exactly how methods get called or
which ones are run.

Ray

Reply via email to