From: Julian Stecklina
Subject: define-method-combination does not work with CMUCL
Date: 
Message-ID: <87k7mvwhi2.fsf@jmmr.no-ip.com>
Hello,

I just tried using define-method-combination to define (you guessed
it) a new method-combination, but CMU CL complains. The example from
CLHS does not work either. Is there a way to work around the problem? 
I intended to write a method combination that should add rgb-colour
values.


CMUCL 18d: 
* (define-method-combination and
         (&optional (order :most-specific-first))
         ((around (:around))
          (primary (and) :order order :required t))
   (let ((form (if (rest primary)
                   `(and ,@(mapcar #'(lambda (method)
                                       `(call-method ,method))
                                   primary))
                   `(call-method ,(first primary)))))
     (if around
         `(call-method ,(first around)
                       (,@(rest around)
                        (make-method ,form)))
         form)))
#<Standard-Method PCL:FIND-METHOD-COMBINATION (GENERIC-FUNCTION (EQL AND) T)
  {48087CB5}>
* (defmethod func and (x y) nil)

Error in function PCL::REAL-INVALID-METHOD-ERROR:
   The method #<Standard-Method FUNC AND (T T)
                {4809C3ED}> has an illegal qualifier.
Standard method combination requires all methods to have one
of the single qualifiers :AROUND, :BEFORE and :AFTER or to
have no qualifier at all.

Restarts:
  0: [ABORT] Return to Top-Level.


Regards,
Julian
-- 
Meine Hompage: http://julian.re6.de

()  ascii ribbon campaign - against html mail
/\                        - against microsoft attachments

From: Tim Bradshaw
Subject: Re: define-method-combination does not work with CMUCL
Date: 
Message-ID: <ey3it2fur20.fsf@cley.com>
* Julian Stecklina wrote:
> Hello,
> I just tried using define-method-combination to define (you guessed
> it) a new method-combination, but CMU CL complains. The example from
> CLHS does not work either. Is there a way to work around the problem? 
> I intended to write a method combination that should add rgb-colour
> values.

I think there are two issues.  If you are defining a GF with a
non-standard method combination then you need to define the GF before
you define any methods on it, and tell it what the MC is.  So you need
to say:

  (defgeneric foo (x)
    (:method-combination my-and))

before defining any methods (note I've used MY-AND, as I think AND is
already taken).

You need to do this because there isn't generally enough information
when the first method is defined to tell what the MC is - lots of MCs
can have the same qualifier (like :AROUND in your case).

The second issue is that, I think, CMUCL is buggy.  I think that
method combination (possibly renamed) should work, and it doesn't seem
to.  I think the problem is that DEFINE-METHOD-COMBINATION doesn't
understand arguments to the MC - if you try a simpler version:

    (define-method-combination my-and
             ()
             ((around (:around))
              (primary (my-and) :order :most-specific-first :required t))
       (let ((form (if (rest primary)
                       `(and ,@(mapcar #'(lambda (method)
                                           `(call-method ,method))
                                       primary))
                       `(call-method ,(first primary)))))
         (if around
             `(call-method ,(first around)
                           (,@(rest around)
                            (make-method ,form)))
             form)))

Then things work.

--tim
From: Gerd Moellmann
Subject: Re: define-method-combination does not work with CMUCL
Date: 
Message-ID: <8665yfovgo.fsf@gerd.free-bsd.org>
Tim Bradshaw <···@cley.com> writes:

> The second issue is that, I think, CMUCL is buggy.  I think that
> method combination (possibly renamed) should work, and it doesn't seem
> to.  I think the problem is that DEFINE-METHOD-COMBINATION doesn't
> understand arguments to the MC

It might be worth trying the patch below (also sent to the CMUCL
maintainers awhile ago).

*** defcombin.lisp	2002/06/18 12:13:23	1.12
--- defcombin.lisp	2002/06/18 12:13:56
***************
*** 259,267 ****
  			   (declare (ignore nms cm-args))
  			   (apply
  			    #'(lambda (generic-function type options)
! 				(declare (ignore generic-function options))
  				(make-instance 'long-method-combination
  					       :type type
  					       :documentation doc))
  			    args))
  	 :definition-source `((define-method-combination ,type)
--- 259,268 ----
  			   (declare (ignore nms cm-args))
  			   (apply
  			    #'(lambda (generic-function type options)
! 				(declare (ignore generic-function))
  				(make-instance 'long-method-combination
  					       :type type
+ 					       :options options
  					       :documentation doc))
  			    args))
  	 :definition-source `((define-method-combination ,type)
From: Pierre R. Mai
Subject: Re: define-method-combination does not work with CMUCL
Date: 
Message-ID: <m2adnqjv98.fsf@ibook.bln.pmsf.net>
Gerd Moellmann <··············@t-online.de> writes:

> Tim Bradshaw <···@cley.com> writes:
>
>> The second issue is that, I think, CMUCL is buggy.  I think that
>> method combination (possibly renamed) should work, and it doesn't seem
>> to.  I think the problem is that DEFINE-METHOD-COMBINATION doesn't
>> understand arguments to the MC
>
> It might be worth trying the patch below (also sent to the CMUCL
> maintainers awhile ago).

And now that I finally came around to work through parts of the PCL
patch queue -- and because of your post -- it has been committed as
well...  Sorry for the delay, but it's been a busy couple of months...

Regs, Pierre.

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein
From: Gerd Moellmann
Subject: Re: define-method-combination does not work with CMUCL
Date: 
Message-ID: <86d6sllr7i.fsf@gerd.free-bsd.org>
Pierre R. Mai <····@acm.org> writes:

> And now that I finally came around to work through parts of the PCL
> patch queue -- and because of your post -- it has been committed as
> well...  

Thank you very much, Pierre.

> Sorry for the delay, but it's been a busy couple of months...

Been there; no need to apologize :-).