[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"))


>> Error: No applicable primary methods for #<STANDARD-GENERIC-FUNCTION ZOG 
>>        Applicable methods: (#<STANDARD-METHOD ZOG :BEFORE (T)>)
>> 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

"Before zog" 

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

"Before zog"