[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

method specalization on defstructs



We have some need to be able to specalize methods on defstructs.
We have been doing this by using pcl:define-built-in-classes
on the names of our defstructs.  When swithching from St-paddys-day
to AAAI pcl we have encountered problems with doing the following:

This is loaded in a file (package view).

(setq *view-built-in-classes*  '((dynamic-struct (t))
				(view-rep-struct (dynamic-struct))
				(point-struct (view-rep-struct))
				(2d-point (point-struct))
))

(setq pcl::*built-in-classes* (append pcl::*built-in-classes*
*view-built-in-classes*))

(pcl::define-built-in-classes)

(defstruct (DYNAMIC-STRUCT)
  dynamic-slot)

Lisp trace:

VIEW> (setq s (make-dynamic-struct))
#S(DYNAMIC-STRUCT DYNAMIC-SLOT NIL)
VIEW> (defmethod blues ((object number))
	(print "blues number"))
BLUES
VIEW> (defmethod blues ((object dynamic-struct))
	(print "blues dynamic-struct"))
BLUES
VIEW> (blues 13)

"blues number" 
"blues number"
VIEW> (blues s)
>>Error: No matching method for the generic-function #<Compiled-Function
BLUES 9B17AE>,
         when called with arguments (#S(DYNAMIC-STRUCT DYNAMIC-SLOT NIL)).

NO-APPLICABLE-METHOD:
   Required arg 0 (GENERIC-FUNCTION): #<Compiled-Function BLUES 9B17AE>
:A  0: Abort to Lisp Top Level

-> :A
Abort to Lisp Top Level
Back to Lisp Top Level

VIEW> (pcl::describe-class (find-class 'dynamic-struct))
The class #<Built-In-Class DYNAMIC-STRUCT 51304616> is an instance of class
#<Standard-Class PCL::BUILT-IN-CLASS 35772146>.
Name:                  DYNAMIC-STRUCT
Class-Precedence-List: (DYNAMIC-STRUCT T)
Local-Supers:          (T)
Direct-Subclasses:     (VIEW-REP-STRUCT)
#<Built-In-Class DYNAMIC-STRUCT 51304616>
VIEW> 



Should this work?? Am I the victim of package problems??
Am I doing something inherently evil?? 
Should I be locked in a closet with the pcl source until
I understand how method lookup works??

JD
jdye@ads.com