Suppose I have
(defmethod foo ((x bar) (eql :baz))
;;....
)
How can I find this method using find-method ? E.g., I mean
how I should continue the following:
(find-method #'foo '() (list (find-class 'bar) .... ?
--
Vladimir Zolotykh ······@eurocom.od.ua
If the MOP is supported in your implementation you can use
INTERN-EQL-SPECIALIZER. For example:
(find-method #'foo nil (list (find-class 'bar)
(aclmop:intern-eql-specializer :baz)))
Tim
In article <·················@eurocom.od.ua>, "Vladimir Zolotykh"
<······@eurocom.od.ua> wrote:
> Suppose I have
> (defmethod foo ((x bar) (eql :baz))
> ;;....
> )
> How can I find this method using find-method ? E.g., I mean how I should
> continue the following:
> (find-method #'foo '() (list (find-class 'bar) .... ?
>
"Tim Moore" <·····@bricoworks.com> writes:
> If the MOP is supported in your implementation you can use
> INTERN-EQL-SPECIALIZER. For example:
>
> (find-method #'foo nil (list (find-class 'bar)
> (aclmop:intern-eql-specializer :baz)))
The gods of portability have stricken you! :)
Cheers
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
In article <···············@octagon.mrl.nyu.edu>, "Marco Antoniotti"
<·······@cs.nyu.edu> wrote:
> "Tim Moore" <·····@bricoworks.com> writes:
>> If the MOP is supported in your implementation you can use
>> INTERN-EQL-SPECIALIZER. For example: (find-method #'foo nil (list
>> (find-class 'bar)
>> (aclmop:intern-eql-specializer
>> :baz)))
> The gods of portability have stricken you! :)
What do you want from me? The OP was asking how to do something that is,
as far as I know, not portable. The MOP spec goes some way towards
enabling one to do this kind of thing portably, but doesn't specify a
package for the MOP symbols. I could have used the package name "MOP",
which exports the MOP symbols in two implementations that I have at hand,
but that might imply that using the MOP is more portable than it is in
practice. For a "one liner" question I don't feel like writing a little
treatise on how to use the MOP somewhat portably.
Insert smileys as necessary.
Tim
Vladimir Zolotykh <······@eurocom.od.ua> writes:
| >
| > (defmethod foo ((x bar) (eql :baz))
| Sorry for mistake. Should be
| (defmethod foo ((x bar) (y (eql :bar)))
Documentation of FIND-METHOD says:
The specializers argument contains the parameter specializers for
the method.
Glossary entry for parameter specializer says:
n. 1. (of a method) an expression which constrains the method to be
applicable only to argument sequences in which the corresponding
argument matches the parameter specializer. 2. a class, or a list
(eql object).
I take it that 2. applies here so you have to continue with
'(eql :bar))). That is:
(find-method #'foo '() (list (find-class 'bar) '(eql :bar)))
Works For Me(tm) in CMUCL. At least Tim Moore seems to disagree
with me about there being a portable way so YMMV.
--
Hannu
In article <··············@lynx.ionific.com>, "Hannu Koivisto"
<·····@iki.fi> wrote:
> Vladimir Zolotykh <······@eurocom.od.ua> writes: | >
> | > (defmethod foo ((x bar) (eql :baz)) | Sorry for mistake. Should be
> | (defmethod foo ((x bar) (y (eql :bar))) Documentation of
> FIND-METHOD says:
> The specializers argument contains the parameter specializers for the
> method.
> Glossary entry for parameter specializer says: n. 1. (of a method) an
> expression which constrains the method to be applicable only to argument
> sequences in which the corresponding argument matches the parameter
> specializer. 2. a class, or a list (eql object).
> I take it that 2. applies here so you have to continue with '(eql
> :bar))). That is:
> (find-method #'foo '() (list (find-class 'bar) '(eql :bar))) Works For
> Me(tm) in CMUCL. At least Tim Moore seems to disagree with me about
> there being a portable way so YMMV.
I didn't read the glossary entry closely enough; I agree with your
reading. Unfortunately, it doesn't work in ACL.
find-method vis a vis the definition of specializers probably suffers
from the attempts to graft MOP-like features into the Spec without
including the (politically impossible) complete MOP.
Tim