From: John Clonts
Subject: Identifying and Distinguishing Methods
Date: 
Message-ID: <3A0B9CF8.EADA800@mastnet.net>
I have two methods

 (defmethod my-function ((x integer)) (cons x :integer))

 (defmethod my-function (( n (eql 10) ))(cons 100 :hundred))

I see that I can refer to the first for example to trace it like:

  (trace ((method my-function (integer))))

But how to do the same for the second, that has the "eql-specializer":

  (trace ((method my-function (eql 10))))  ; doesnt work
  Error: `(method my-function (eql 10))' is not fbound

Thanks,
John

P.S. Using acl6_trial

From: Kent M Pitman
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <sfw7l6coy2v.fsf@world.std.com>
John Clonts <·······@mastnet.net> writes:

> I have two methods
> 
>  (defmethod my-function ((x integer)) (cons x :integer))
> 
>  (defmethod my-function (( n (eql 10) ))(cons 100 :hundred))
> 
> I see that I can refer to the first for example to trace it like:
> 
>   (trace ((method my-function (integer))))
> 
> But how to do the same for the second, that has the "eql-specializer":
> 
>   (trace ((method my-function (eql 10))))  ; doesnt work
>   Error: `(method my-function (eql 10))' is not fbound

You should specify an implementation and version since
this is implementation-dependent, i.e., beyond the scope of the spec,
but doesn't

 (trace ((method my-function ((eql 10)))))

work?  (It does in LispWorks 4.1, for example.)

(Note that (method my-function (eql 10)), which you used, specifies 
purported classes for two arguments, one of class EQL and one of class 10,
which of course aren't valid classes.)
From: John Clonts
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <3A0C181E.1C99A1AB@mastnet.net>
Kent M Pitman wrote:
> 
> John Clonts <·······@mastnet.net> writes:
> 
> > I have two methods
> >
> >  (defmethod my-function ((x integer)) (cons x :integer))
> >
> >  (defmethod my-function (( n (eql 10) ))(cons 100 :hundred))
> >
> > I see that I can refer to the first for example to trace it like:
> >
> >   (trace ((method my-function (integer))))
> >
> > But how to do the same for the second, that has the "eql-specializer":
> >
> >   (trace ((method my-function (eql 10))))  ; doesnt work
> >   Error: `(method my-function (eql 10))' is not fbound
> 
> You should specify an implementation and version since
> this is implementation-dependent, i.e., beyond the scope of the spec,
> but doesn't
> 
>  (trace ((method my-function ((eql 10)))))
> 
> work?  (It does in LispWorks 4.1, for example.)
> 
> (Note that (method my-function (eql 10)), which you used, specifies
> purported classes for two arguments, one of class EQL and one of class 10,
> which of course aren't valid classes.)

Kent,

Ok, thanks.  I thought I had tried that but I see that it works for me.  

Now I have been looking at find-method and remove-method, and notice
that they use a different means entirely for specifying the method:

  (trace ((method my-function (integer))))
but
  (find-method #'my-function nil (list (find-class 'integer)))

and

  (trace ((method my-function ((eql 10)))))
but
  (find-method #'my-function nil (list (mop:intern-eql-specializer 10)))


1) I couldn't really tell if the mop:intern-eql-specializer is standard,
or is it a Franz-ism (I'm using acl 6).

2) What is the role of "method" in the trace example above?

Thanks,
John

(mailed and posted an equivalent on c.l.l)
From: Barry Margolin
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <vBYO5.65$sG1.791@burlma1-snr2>
In article <·················@mastnet.net>,
John Clonts  <·······@mastnet.net> wrote:
>2) What is the role of "method" in the trace example above?

It's similar to the role of "setf" in

(defun (setf xxx) ...)

Just as the name of a setf function is the list (setf <accessor>), the name
of a method is (method <gf-name> <qualifiers> (<arg-specializers>)).
However, while (setf ...) is part of the ANSI standard, (method ...) is an
implementation extension.  It allows you to refer to methods in parameters
to macros like TRACE (since it doesn't evaluate its arguments, you can't
call MOP functions to look up the method).

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Steven Haflich
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <3A0C6252.EA34D31C@pacbell.net>
John Clonts wrote:

> 1) I couldn't really tell if the mop:intern-eql-specializer is standard,
> or is it a Franz-ism (I'm using acl 6).

Symbols exported from the mop package are those specified by the
standard (but unofficial) definition of the CL metaobject protocol
specified in _The Art of the Metaobject Protocol_, Kiczales et al,
1991.  In that sense, they are standard.
From: David Bakhash
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <m3hf5f8ze8.fsf@cadet.dsl.speakeasy.net>
Steven Haflich <·······@pacbell.net> writes:

> > 1) I couldn't really tell if the mop:intern-eql-specializer is
> > standard, or is it a Franz-ism (I'm using acl 6).
> 
> Symbols exported from the mop package are those specified by the
> standard (but unofficial) definition of the CL metaobject protocol
> specified in _The Art of the Metaobject Protocol_, Kiczales et al,
> 1991.  In that sense, they are standard.

I'd assume that symbols exported from the CLOS package are safe to
use.  If it's an unexported symbol from the CLOS package, then I'd try
to avoid it.

dave
From: Robert Monfera
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <3A0CBB9E.29295275@fisec.com>
John Clonts wrote:

>  (trace ((method my-function ((eql 10)))))
> but
>   (find-method #'my-function nil (list (mop:intern-eql-specializer 10)))
> 
> 1) I couldn't really tell if the mop:intern-eql-specializer is standard,
> or is it a Franz-ism (I'm using acl 6).

MOP is described in a book titled The Art of Metaobject Protocol, and it
is a de facto standard.  Intern-eql-specializer is part of it.  The
reference says, "The result is the eql specializer metaobject for
object."

You can either get the AMOP book (being very educational, it's
recommended) or look at the reference part of AMOP in the MOP section of
the ACL documentation.

> 2) What is the role of "method" in the trace example above?

If you have the ACL documentation, take a look at the section on
function specs in implementation.htm.  There are alternative functions
to specify, for example FLETs.

Robert
From: Pekka P. Pirinen
Subject: Re: Identifying and Distinguishing Methods
Date: 
Message-ID: <ixu299hxwi.fsf@harlequin.co.uk>
John Clonts <·······@mastnet.net> writes:
>   (find-method #'my-function nil (list (mop:intern-eql-specializer 10)))
> 
> 1) I couldn't really tell if the mop:intern-eql-specializer is standard,
> or is it a Franz-ism (I'm using acl 6).

It's an AMOPism, as Steve Haflich said.  It's not something you need
to use with any standard function, as the list (EQL <object>) is a
standard parameter specializer.
  (find-method #'my-function nil (list '(eql 10)))
You might need it when calling some ACL MOP function.
-- 
Pekka P. Pirinen
Heard at OOPSLA 2000: We didn't pick the best solution [for the architecture],
because it would have required C++ programmers who understand the language.
From: John Clonts
Subject: EQL Specializer (bug?) in ACL [was Re: Identifying and Distinguishing Methods]
Date: 
Message-ID: <3A133D71.6240C9A2@mastnet.net>
Pekka P. Pirinen wrote:
> 
> John Clonts <·······@mastnet.net> writes:
> >   (find-method #'my-function nil (list (mop:intern-eql-specializer 10)))
> >
> > 1) I couldn't really tell if the mop:intern-eql-specializer is standard,
> > or is it a Franz-ism (I'm using acl 6).
> 
> It's an AMOPism, as Steve Haflich said.  It's not something you need
> to use with any standard function, as the list (EQL <object>) is a
> standard parameter specializer.
>   (find-method #'my-function nil (list '(eql 10)))

Excellent!  This is what I was after.  I suppose the reason I didn't
find it is because ACL complains:

  Error: The generic function #<standard-generic-function my-function>
does not
         have a method with qualifiers nil specializers ((eql 10))
    [condition type: program-error]

But, I found that CMUCL worked as you said...

Cheers,
John

P.S. complete code follows

 (defmethod my-function ((x integer)) (cons x :integer))

 (defmethod my-function (( n (eql 10) ))(cons 100 :hundred))

 (find-method #'my-function nil (list '(eql 10)))
From: Stig E. Sandø
Subject: Re: EQL Specializer (bug?) in ACL
Date: 
Message-ID: <87vgtmhn01.fsf_-_@palomba.bananos.org>
John Clonts <·······@mastnet.net> writes:

> Pekka P. Pirinen wrote:
> > 
> > John Clonts <·······@mastnet.net> writes:
> > >   (find-method #'my-function nil (list (mop:intern-eql-specializer 10)))
> > >
> > > 1) I couldn't really tell if the mop:intern-eql-specializer is standard,
> > > or is it a Franz-ism (I'm using acl 6).
> > 
> > It's an AMOPism, as Steve Haflich said.  It's not something you need
> > to use with any standard function, as the list (EQL <object>) is a
> > standard parameter specializer.
> >   (find-method #'my-function nil (list '(eql 10)))
> 
> Excellent!  This is what I was after.  I suppose the reason I didn't
> find it is because ACL complains:
> 
>   Error: The generic function #<standard-generic-function my-function>
> does not
>          have a method with qualifiers nil specializers ((eql 10))
>     [condition type: program-error]

I think this is a bug, ie the code below does not work with ACL6
trial (but I am pretty sure it worked with ACL5, and it works with
CLISP and CMUCL):

(in-package :cl-user)

(defpackage :biff
  (:use :common-lisp)
  (:export #:foo))

(defpackage :bobby
  (:use :common-lisp :biff))

(in-package :biff)

(defgeneric foo (bar)
  (:method :after (bar)
	   (warn "after")))

(in-package :bobby)

(defmethod foo ((bar (eql :xyzzy)))
  (warn "xyzzy"))

;(foo :xyzzy)
;(in-package :cl-user)
;(biff:foo :xyzzy)CC
-----

It is kindof vital that this work because I do have interfaces in a
package :biff and separate implementations in :bobby-alike paclages.
Am I doing something wrong which I miss entirely?  (The code works
when the method also is in package :biff)


-- 
------------------------------------------------------------------
Stig Erik Sandoe     ····@ii.uib.no    http://www.ii.uib.no/~stig/