[comp.lang.clos] Bug in May Day PCL

hohl@diana.informatik.uni-stuttgart.de (Hubertus Hohl) (02/08/91)

Slot access in the new Revision 4 PCL [May Day PCL (REV 4)] does not always 
work correctly. Consider the following code fragment (extracted
from a more complex piece of code):
  
   (defclass thing ()
     ((t-1 :initform 999)))

   (defmethod m1 ((maybe-a-thing t))
     (if (typep maybe-a-thing 'thing)
         (slot-value maybe-a-thing 't-1)
         maybe-a-thing))

   (m1 (make-instance 'thing)) => 999

   (m1 'foo)  => 
   Error: No matching method for the generic-function #<Function FIND-SLOT-DEFINITION @ #x47fcbe>,
   when called with arguments (#<Built-In-Class SYMBOL 23723516> T-1).

Of course, I know that method M1 could (and should) be replaced by 
two methods M1 that specialize on THING and T respectively! Anyway, this 
behaviour did not show up in May Day PCL (REV 3). 
Any bug fixes would be appreciated, especially from the people who contributed
to Revision 4!

Thanks in advance.

==============================================================================
Hubertus Hohl                     e-mail: hohl@dia.informatik.uni-stuttgart.de
Institut fuer Informatik
Herdweg 51
D - 7000 Stuttgart 1                               Tel.:  (+49|0) 711 121 1358
==============================================================================
-- 

==============================================================================
Hubertus Hohl                 e-mail: hohl@dia.informatik.uni-stuttgart.dbp.de
Institut fuer Informatik

Gregor@parc.xerox.com (Gregor Kiczales) (02/09/91)

   Date: 	Thu, 7 Feb 1991 23:42:46 PST
   From: hohl%ifistg.uucp@ira.uka.de (Hubertus Hohl)

   Slot access in the new Revision 4 PCL [May Day PCL (REV 4)] does
   not always work correctly. Consider the following code fragment
   (extracted from a more complex piece of code):

      (defmethod m1 ((maybe-a-thing t))
	(if (typep maybe-a-thing 'thing)
	    (slot-value maybe-a-thing 't-1)
	    maybe-a-thing))

      (m1 (make-instance 'thing)) => 999

      (m1 'foo)  =>
      Error: No matching method for the generic-function #<Function FIND-SLOT-DEFINITION @ #x47fcbe>,
      when called with arguments (#<Built-In-Class SYMBOL 23723516>
T-1).

The bug here isn't with slot access, its with TYPEP.  PCL doesn't
redefine typep to know about CLOS classes.  You need to use the special
version of TYPEP provided by PCL.