From: Pascal Costanza
Subject: What's wrong with this combination?
Date: 
Message-ID: <3D942F3F.6060905@web.de>
Hi,

I have the following definition:

(define-method-combination java-method
     ((methods *))
   (:arguments &key mode class)
   (flet ((class-qual-p (meth)
            (member class (method-qualifiers meth))))
     (ccase mode
       (:default
        (call-method (car methods)))
       (:special
        (call-method (find-if #'class-qual-p methods)))
       (:super
        (call-method (cadr (member-if #'class-qual-p methods)))))))

As far as I understand the specs, this should be a reasonable method 
combination.

However, in MCL I get a warning which talks about "&key" being an unused 
lexical variable (?!?), and LispWorks even gives me an error that says 
that ":arguments is not of type CONS".

Does anybody have an idea what's going on here?

Thanks a lot in advance,
Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)

From: Wolfhard Buß
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <m3lm5n4su6.fsf@buss-14250.user.cis.dfn.de>
Pascal Costanza
> I have the following definition:
> 
> (define-method-combination java-method
>      ((methods *))
>    (:arguments &key mode class)
>    (flet ((class-qual-p (meth)
>             (member class (method-qualifiers meth))))
>      (ccase mode
>        (:default
>         (call-method (car methods)))
>        (:special
>         (call-method (find-if #'class-qual-p methods)))
>        (:super
>         (call-method (cadr (member-if #'class-qual-p methods)))))))
> 
> As far as I understand the specs, this should be a reasonable method
> combination.

The long form of the define-method-combination macro requires a
define-method-combination arguments lambda list.

 (define-method-combination java-method () ...)

-- 
"I believe in the horse. The automobile is a passing phenomenon."
                              --  Kaiser Wilhelm II. (1859-1941)
From: Pascal Costanza
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <an248s$aud$1@newsreader2.netcologne.de>
Wolfhard Bu� wrote:
> Pascal Costanza
> 
>>I have the following definition:

[skipped, see below]

>>As far as I understand the specs, this should be a reasonable method
>>combination.
> 
> The long form of the define-method-combination macro requires a
> define-method-combination arguments lambda list.
> 
>  (define-method-combination java-method () ...)

Oh yes, sure - I didn't have the sources at hand, I have just retyped 
it. Here is a corrected version:

(define-method-combination java-method ()
     ((methods *))
   (:arguments &key mode class)
   (flet ((class-qual-p (meth)
            (member class (method-qualifiers meth))))
     (ccase mode
       (:default
        `(call-method ,(car methods)))
       (:special
        `(call-method ,(find-if #'class-qual-p methods)))
       (:super
        `(call-method ,(cadr (member-if #'class-qual-p methods)))))))

So this should work in LispWorks (I cannot check this right now), but 
still gives the error message in MCL... :-(

Pascal
From: Pascal Costanza
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <3D98251D.6020704@web.de>
OK, MCL seems to have a bug and does not correctly parse keyword 
arguments in the :arguments section of a method combination. So here is 
another version of my "java-method" combination that does what I want 
without keyword arguments:

(define-method-combination java-method ()
                            ((methods *))
   (:arguments this locals mode class)
; (declare (ignore this locals))
   (flet ((class-qual-p (meth)
            (member class (method-qualifiers meth))))
     (ccase mode
       (:default
        `(call-method ,(car methods)))
       (:special
        `(call-method ,(find-if #'class-qual-p methods)))
       (:super
        `(call-method ,(cadr (member-if #'class-qual-p methods)))))))

Now I get a warning in both MCL and LispWorks that "this" and "locals" 
are not used. I tried to declare them as arguments that should be 
ignored (see commented line above), but this doesn't work.

Is there a way to suppress the compiler warning?


Thanks a lot in advance,
Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
From: Thomas A. Russ
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <ymiofafc8pu.fsf@sevak.isi.edu>
Pascal Costanza <········@web.de> writes:

> 
> Now I get a warning in both MCL and LispWorks that "this" and "locals" 
> are not used. I tried to declare them as arguments that should be 
> ignored (see commented line above), but this doesn't work.
> 
> Is there a way to suppress the compiler warning?

Declare them to be IGNORABLE.  This will work in MCL, I'm not sure about
LispWorks.

I occassionally run into this in MCL, for example in code like:

  (let (first second)
    ....
    (multiple-value-setq (first second) (...))
 
    (... second ...))

Where "first" is only set, but never read.  MCL complains that it is
never used, since being used requires (in MCL) reading the value.  But
if it is declared IGNORE, a different complaint arises when the
supposedly ignored variable is set.  Oh well.


> 
> Thanks a lot in advance,
> Pascal
> 
> -- 
> Pascal Costanza               University of Bonn
> ···············@web.de        Institute of Computer Science III
> http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
> 

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Pascal Costanza
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <and6b0$g3g$1@newsreader2.netcologne.de>
Thomas A. Russ wrote:
> Pascal Costanza <········@web.de> writes:
> 
>>Now I get a warning in both MCL and LispWorks that "this" and "locals" 
>>are not used. I tried to declare them as arguments that should be 
>>ignored (see commented line above), but this doesn't work.
>>
>>Is there a way to suppress the compiler warning?
> 
> Declare them to be IGNORABLE.  This will work in MCL, I'm not sure about
> LispWorks.
> 

Nope, in this case, in conjunction with the :arguments declaration in a 
user-defined method combination, it doesn't work.

Pascal
From: Wolfhard Buß
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <m3heg7h4wl.fsf@buss-14250.user.cis.dfn.de>
Pascal Costanza
> OK, MCL seems to have a bug and does not correctly parse keyword
> arguments in the :arguments section of a method combination.
> Now I get a warning in both MCL and LispWorks ...
:
> Is there a way to suppress the compiler warning?

I don't know.  But I hope, that some readers of cll will post the
result of (foo 42), as computed by their listeners. I fear, that
some implementations of define-method-combination fail to process
the :arguments and/or :generic-function forms as expected.

 (define-method-combination foo ()
   ((methods *))
   (:arguments &whole arguments)
   (:generic-function gf)
   (declare (ignore methods))
   `(format t "~&generic function ~A applied to ~A~%"
     (mop:generic-function-name ,gf) ,arguments))

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

cmucl's (pcl) method combination macro doesn't work, when supplied
with an :arguments form.

-- 
"I believe in the horse. The automobile is a passing phenomenon."
                              --  Kaiser Wilhelm II. (1859-1941)
From: Pascal Costanza
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <3D987313.9090805@web.de>
Wolfhard Bu� wrote:
> Pascal Costanza
> 
>>OK, MCL seems to have a bug and does not correctly parse keyword
>>arguments in the :arguments section of a method combination.
>>Now I get a warning in both MCL and LispWorks ...
> 
> :
> 
>>Is there a way to suppress the compiler warning?
> 
> 
> I don't know.  But I hope, that some readers of cll will post the
> result of (foo 42), as computed by their listeners. I fear, that
> some implementations of define-method-combination fail to process
> the :arguments and/or :generic-function forms as expected.
> 
>  (define-method-combination foo ()
>    ((methods *))
>    (:arguments &whole arguments)
>    (:generic-function gf)
>    (declare (ignore methods))
>    `(format t "~&generic function ~A applied to ~A~%"
>      (mop:generic-function-name ,gf) ,arguments))
> 
>  (defgeneric foo (x)
>    (:method-combination foo)
>    (:method foo (x) x))
> 
> cmucl's (pcl) method combination macro doesn't work, when supplied
> with an :arguments form.

Hmm, I don't know if this is could be the problem, but there's an actual 
method definition missing in your example. Here is the snippet again 
with minor modifications for LispWorks:

(define-method-combination foo ()
    ((methods *))
    (:arguments &whole arguments)
    (:generic-function gf)
    (declare (ignore methods))
    `(format t "~&generic function ~A applied to ~A~%"
      (generic-function-name ,gf) ,arguments))

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

(defmethod foo (x)
   x)

LispWorks returns the following:

CL-USER 14 > (foo 42)
generic function FOO applied to #<unbound>
NIL

So this means that LispWorks doesn't process the :arguments as expected 
as well, right?!?

The same stuff will probably also not work in MCL because I don't expect 
it to handle the &whole declaration as well. I am going to test this 
this evening...

Is there any implementation that does these things right?

Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
From: Wolfhard Buß
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <m3d6qvgzws.fsf@buss-14250.user.cis.dfn.de>
Pascal Costanza
> there's an actual method definition missing in your example.

No. The example defines a method with method-qualifier foo for a
generic function foo with method-combination foo.

> LispWorks returns the following:
> 
> CL-USER 14 > (foo 42)
> generic function FOO applied to #<unbound>
> NIL
> 
> So this means that LispWorks doesn't process the :arguments as
> expected as well, right?!?

Yes.

> Is there any implementation that does these things right?

I hope so.

-- 
"I believe in the horse. The automobile is a passing phenomenon."
                              --  Kaiser Wilhelm II. (1859-1941)
From: Pascal Costanza
Subject: Re: What's wrong with this combination?
Date: 
Message-ID: <anacfq$ckl$1@newsreader2.netcologne.de>
Wolfhard Bu� wrote:
> Pascal Costanza
> 
>>there's an actual method definition missing in your example. >
> 
> No. The example defines a method with method-qualifier foo for a
> generic function foo with method-combination foo.

Yes, it does. Sorry, this was my fault - I didn't pay enough attention. 
LispWorks doesn't seem to recognize the function definition in this 
case. (?!?)

>>So this means that LispWorks doesn't process the :arguments as
>>expected as well, right?!?
> 
> Yes.

Neither does MCL. :(

>>Is there any implementation that does these things right?
> 
> I hope so.

Me too. Are we really the first ones on earth to check if this feature 
works? ;)

Pascal