[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

api for method-combination meta objects

Jim Newton

3/25/2016 10:44:00 AM

Looking at http://mop.lisp.se/concepts.html#method-c...
it says explicitly that the structure of and implicitly the API
of method-combination meta objects are not documented.

I took a look in closer-mop, and I don't see where it defines a standard
interface either.

My question is: once I've called (generic-function-method-combination gf)
and obtained a method-combination meta-object, how can I find out
whether it is the standard-method-combination?

I see that in sbcl, the name of the class of the object is sb-pcl:standard-method-combination,
but if I check (typep comb 'sb-pcl:standard-method-combination) it will only work
in SBCL.

Isn't there a better way?
7 Answers

Pascal Costanza

3/26/2016 2:17:00 PM

0

On 25/03/16 11:44, Jim Newton wrote:
> Looking at http://mop.lisp.se/concepts.html#method-c...
> it says explicitly that the structure of and implicitly the API
> of method-combination meta objects are not documented.
>
> I took a look in closer-mop, and I don't see where it defines a standard
> interface either.
>
> My question is: once I've called (generic-function-method-combination gf)
> and obtained a method-combination meta-object, how can I find out
> whether it is the standard-method-combination?
>
> I see that in sbcl, the name of the class of the object is sb-pcl:standard-method-combination,
> but if I check (typep comb 'sb-pcl:standard-method-combination) it will only work
> in SBCL.
>
> Isn't there a better way?

I don't think there is.

The meta-level interface to method combinations is not specified in any
way, and implementations vary wildly how they actually implement them.

The reason for this might that define-method-combination is already a
meta-programming interface for combining methods, so the thinking was
maybe that it's not necessary to specify yet another meta-level
interface for it.

Note that you can define methods on compute-effective-method to control
method combination.

Pascal

--
My website: http:/...
Common Lisp Document Repository: http://cdr.eu...
Closer to MOP & ContextL: http://common-lisp.net/proje...
The views expressed are my own, and not those of my employer.

Jim Newton

3/29/2016 8:52:00 AM

0

On Saturday, March 26, 2016 at 3:17:35 PM UTC+1, Pascal Costanza wrote:
> On 25/03/16 11:44, Jim Newton wrote:

>
> I don't think there is.
>
> The meta-level interface to method combinations is not specified in any
> way, and implementations vary wildly how they actually implement them.
>
> Pascal
>

Thanks for the clue. What's your suggestion for the following task? I want to find all methods
whose specializers obey a certain relationship, defined by my application. But I only want to
work on generic functions which use the standard method combination, because I know
my relationship is not valid for those.

Didier Verna

3/29/2016 9:03:00 AM

0

Pascal Costanza wrote:

> The meta-level interface to method combinations is not specified in
> any way, and implementations vary wildly how they actually implement
> them.

and some of them do peculiar things...
http://www.didierverna.net/blog/index.php?post/2013/08/16/Lisp-Corner-Cases%3A-Method-Co...

--
Resistance is futile. You will be jazzimilated.

Jazz site: http://www.didie...
Other sites: http://www.didier...

Jim Newton

3/29/2016 11:31:00 AM

0

The way I've decided to do it is the following:

Define a dummy generic function, dummy, using the standard-method-combination.
Get its method combination object with
(generic-function-method-combination (fdefinition 'dummy))

Now, given a generic function meta object, gf, compare the return value of
(generic-function-method-combination gf) to (generic-function-method-combination (fdefinition 'dummy))

That seems to work in sbcl. I have not tested it anywhere else yet.

Pascal Costanza

4/2/2016 11:27:00 AM

0

On 29/03/16 13:31, Jim Newton wrote:
> The way I've decided to do it is the following:
>
> Define a dummy generic function, dummy, using the standard-method-combination.
> Get its method combination object with
> (generic-function-method-combination (fdefinition 'dummy))
>
> Now, given a generic function meta object, gf, compare the return value of
> (generic-function-method-combination gf) to (generic-function-method-combination (fdefinition 'dummy))
>
> That seems to work in sbcl. I have not tested it anywhere else yet.

According to the CLOS MOP specification, this is probably not portable.
The method combination metaobject for a generic function is determined
by a call to find-method-combination, and f-m-c has no restrictions on
what objects to return, so it could be a different one for every generic
function even if the method combination name is always the same.

You could define a :before, :after, or :around method on
find-method-combination for your own generic function metaobject class
to grab the method combination name and compare on that name.


Pascal

--
My website: http:/...
Common Lisp Document Repository: http://cdr.eu...
Closer to MOP & ContextL: http://common-lisp.net/proje...
The views expressed are my own, and not those of my employer.

Jim Newton

4/4/2016 8:04:00 AM

0


> According to the CLOS MOP specification, this is probably not portable.

Yes, I can well imagine. I considered setting up some load-time assertions
which will verify my assumptions about the uniqueness of the meta objects.


> You could define a :before, :after, or :around method on
> find-method-combination for your own generic function metaobject class
> to grab the method combination name and compare on that name.

Could you elaborate a bit. I don't understand. How would I get the "name"
of the method combination? I think if I could get that, it might solve the
the problem in a much simpler way.

Pascal Costanza

4/9/2016 11:58:00 AM

0

On 04/04/16 10:04, Jim Newton wrote:
>
>> According to the CLOS MOP specification, this is probably not portable.
>
> Yes, I can well imagine. I considered setting up some load-time assertions
> which will verify my assumptions about the uniqueness of the meta objects.
>
>
>> You could define a :before, :after, or :around method on
>> find-method-combination for your own generic function metaobject class
>> to grab the method combination name and compare on that name.
>
> Could you elaborate a bit. I don't understand. How would I get the "name"
> of the method combination? I think if I could get that, it might solve the
> the problem in a much simpler way.

The name is the second argument to find-method-combination which you can
grab whenever find-method-combination is called. Somewhere between
defgeneric/ensure-generic-function and make-instance of the generic
function metaobject class, find-method-combination should be called to
convert the method combination name into a method combination
metaobject, and there is hope that find-method-combination is used for
these purposes (alas, that is not specified - sigh...)

Pascal

--
My website: http:/...
Common Lisp Document Repository: http://cdr.eu...
Closer to MOP & ContextL: http://common-lisp.net/proje...
The views expressed are my own, and not those of my employer.