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

Re: eql-specialized methods and before



On Fri Feb 111994 Bob Hall writes:
> Is the following a bug, or am I doing something wrong?  It works okay
> if I don't define the :BEFORE method.
> 
> (DEFMETHOD ZOG ((X (EQL :NORJ))) (print "Zognorj!"))
> (DEFMETHOD ZOG ((X (EQL :BLID))) (PRINT "Zogblid!"))
> (DEFMETHOD ZOG :BEFORE ((X T)) (PRINT "Before zog"))

> (ZOG :NORJ)

>> Error: No applicable primary methods for #<STANDARD-GENERIC-FUNCTION ZOG 
#x56>
>>        Applicable methods: (#<STANDARD-METHOD ZOG :BEFORE (T)>)
>> While executing: CCL::%METHOD-COMBINATION-ERROR
>> Type Command-. to abort.

If you're going to use a before, after, or around methods (e.g.
  (defmethod zog :before ...
  (defmethod zog :after ...
  (defmethod zog :around ...
you'll need to define a primary method The :before method is invoked before
any other method, the after method after.


The problems disappear if you add the following
(defmethod zog ((x t)) 
	(declare (ignore x)

Then it works correctly
? (ZOG :NORJ)

"Before zog" 
"Zognorj!" 
"Zognorj!"

If you add an after method
(defmethod zog :after ((x t)) (print :after) t)

? (ZOG :NORJ)
"Before zog" 
"Zognorj!" 
:AFTER 
"Zognorj!"

mark