From: Pillsy
Subject: [MOPish] A question about ADD-METHOD and closures.
Date: 
Message-ID: <1188320029.515658.91200@22g2000hsm.googlegroups.com>
Is there any way to use ADD-METHOD to add a closure (with additional
information about specializers and qualifiers, of course) as a method
to a generic function? I've been trying to understand the AMOP
documentation, and I'm not seeing it. (It looks like this is outside
the standard and need to use the metaobject protocol, but I could be
wrong.)

Or is this one of those, "It hurts when I do this!"/"Well, don't do
that then!" situations?

Cheers,
Pillsy

From: Geoff Wozniak
Subject: Re: A question about ADD-METHOD and closures.
Date: 
Message-ID: <1188337188.076633.291250@r29g2000hsg.googlegroups.com>
On Aug 28, 12:53 pm, Pillsy <·········@gmail.com> wrote:
> Is there any way to use ADD-METHOD to add a closure (with additional
> information about specializers and qualifiers, of course) as a method
> to a generic function? I've been trying to understand the AMOP
> documentation, and I'm not seeing it. (It looks like this is outside
> the standard and need to use the metaobject protocol, but I could be
> wrong.)
>

ADD-METHOD requires a method object, of which a closure is not.  You
can make methods with MAKE-METHOD, but that is only in specialized
situations.  You'd be better off using the MOP.

I recommend checking out CLOSER-MOP [1] to do these things.  It has
the function ENSURE-METHOD that can make method objects for you from
lambda expressions.  The more low-level way to do it involves MAKE-
METHOD-LAMBDA followed by a call to MAKE-INSTANCE.

> Or is this one of those, "It hurts when I do this!"/"Well, don't do
> that then!" situations?
>

That depends.  What are you doing? :)

[1] http://common-lisp.net/project/closer/closer-mop.html
From: Pillsy
Subject: Re: A question about ADD-METHOD and closures.
Date: 
Message-ID: <1188386811.436379.177590@y42g2000hsy.googlegroups.com>
On Aug 28, 5:39 pm, Geoff Wozniak <·············@gmail.com> wrote:

> On Aug 28, 12:53 pm, Pillsy <·········@gmail.com> wrote:

> > Is there any way to use ADD-METHOD to add a closure (with additional
> > information about specializers and qualifiers, of course) as a method
> > to a generic function? I've been trying to understand the AMOP
> > documentation, and I'm not seeing it. (It looks like this is outside
> > the standard and need to use the metaobject protocol, but I could be
> > wrong.)

> ADD-METHOD requires a method object, of which a closure is not.  You
> can make methods with MAKE-METHOD, but that is only in specialized
> situations.  You'd be better off using the MOP.

> I recommend checking out CLOSER-MOP [1] to do these things.  It has
> the function ENSURE-METHOD that can make method objects for you from
> lambda expressions.  The more low-level way to do it involves MAKE-
> METHOD-LAMBDA followed by a call to MAKE-INSTANCE.

Using MAKE-METHOD-LAMBDA and MAKE-INSTANT let me do exactly what I
wanted to, but I couldn't figure out why it was what I wanted until I
looked at the sources for ENSURE-METHOD. Thanks for the help.

Cheers,
Pillsy