ENSURE-GENERIC-FUNCTION and method combinations? 
Author Message
 ENSURE-GENERIC-FUNCTION and method combinations?

(ensure-generic-function 'baz :method-combination '(standard))

Should this syntax work? ANSI CL speaks of an
method combination *object*.  

If not: how do I get the method combination object?

(define-method-combination foo ...)

(ensure-generic-function 'bar
   :method-combination ... ; here I want foo
   )

--
http://www.*-*-*.com/ ~joswig



Wed, 28 Mar 2001 03:00:00 GMT  
 ENSURE-GENERIC-FUNCTION and method combinations?

Quote:

> (ensure-generic-function 'baz :method-combination '(standard))

> Should this syntax work? ANSI CL speaks of an
> method combination *object*.

> If not: how do I get the method combination object?

> (define-method-combination foo ...)

> (ensure-generic-function 'bar
>    :method-combination ... ; here I want foo
>    )

> --
> http://www.lavielle.com/~joswig

ANSI says:

  The :METHOD-COMBINATION option of DEFGENERIC is used to specify that
  a generic function should use a particular method combination
  type. The first argument to the :METHOD-COMBINATION option is the
  name of a method combination type and the remaining arguments are
  options for that type.

Thus, for one can write:

(defgeneric baz (...)
  (:method-combination standard))

(defgeneric bar (...)
  (:method-combination foo))

Alas, the MOP explictly does not define either how the
:METHOD-COMBINATION option to DEFGENERIC is canonicalized or how the
:METHOD-COMBINATION initarg for generic-function is
interpreted/canonicalized.

My view is that a reasonable implementation of DEFGENERIC would be to
gather the :METHOD-COMBINATION name and options in a list and use this
as the value of the :METHOD-COMBINATION initarg.  Then let
ENSURE-GENERIC-FUNCTION sort it out.  You should be able to
macroexpand DEFGENERIC in your implementation to see if this is so.

If defgeneric does work this way, then ENSURE-GENERIC-FUNCTION must
accept either a method-combination object (if the implementation
follows the MOP) or a list of method-combiantion name and options.
(It might also be nice if a symbol (i.e., a name with no options) is
also recognized, but that's up to the implementation.)

The MOP also defines FIND-METHOD-COMBINATION, but it requires both a
generic-function metaobject as well as a method-combination-type-name
and list of method-combination-options as arguments.  My interpretation
is that the generic-function argument can be a prototype or any other
gf laying around that has the right metaclass. The gf is used ONLY as
a hook so that users can define their own way to convert
name/option combinations to real method-combination objects by
defining a specialized method on some user-defined generic-function
class.  Of course, others might disagree with this interpretation.



Sat, 31 Mar 2001 03:00:00 GMT  
 ENSURE-GENERIC-FUNCTION and method combinations?

Quote:


> > (ensure-generic-function 'baz :method-combination '(standard))

> > Should this syntax work? ANSI CL speaks of an
> > method combination *object*.

> > If not: how do I get the method combination object?

> > (define-method-combination foo ...)

> > (ensure-generic-function 'bar
> >    :method-combination ... ; here I want foo
>   The :METHOD-COMBINATION option of DEFGENERIC

DEFGENERIC is clear to me. But what about "ensure-generic-function".
It is defined in ANSI CL, but nowhere it says how to create
and get method combination objects.

Quote:
> ENSURE-GENERIC-FUNCTION sort it out.  You should be able to
> macroexpand DEFGENERIC in your implementation to see if this is so.

MCL doesn't give me a clue.

Quote:
> If defgeneric does work this way, then ENSURE-GENERIC-FUNCTION must
> accept either a method-combination object (if the implementation
> follows the MOP) or a list of method-combiantion name and options.
> (It might also be nice if a symbol (i.e., a name with no options) is
> also recognized, but that's up to the implementation.)

> The MOP also defines FIND-METHOD-COMBINATION, but it requires both a
> generic-function metaobject as well as a method-combination-type-name
> and list of method-combination-options as arguments.  My interpretation
> is that the generic-function argument can be a prototype or any other
> gf laying around that has the right metaclass. The gf is used ONLY as
> a hook so that users can define their own way to convert
> name/option combinations to real method-combination objects by
> defining a specialized method on some user-defined generic-function
> class.  Of course, others might disagree with this interpretation.

Hmm, still I don't understand why there isn't a FIND-METHOD-COMBINATION
(maybe also accepting nil as the argument for the generic function).
I want to feed ENDURE-GENERIC-FUNCTION the right arguments,
but how do I get these (the method combination metaobject)
in ANSI CL? If you look at the HyperSpec you see that the
explanation for the method-combination option has no
link into the glossary. Seems like this is left for future work...

--
http://www.lavielle.com/~joswig



Sat, 31 Mar 2001 03:00:00 GMT  
 ENSURE-GENERIC-FUNCTION and method combinations?

Quote:

>DEFGENERIC is clear to me. But what about "ensure-generic-function".
>It is defined in ANSI CL, but nowhere it says how to create
>and get method combination objects.

You need to use the MOP for that.  ANSI CL assumes the existence of a MOP,
but leaves its definition for the future.  This function probably should
never have been left in as part of the standard, since it's much more like
MOP than regular CLOS, and I think we simply screwed up.  But as long as
you don't use the MOP-related options, it's reasonable to use it in
standard code.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.



Sat, 31 Mar 2001 03:00:00 GMT  
 ENSURE-GENERIC-FUNCTION and method combinations?

Quote:

> DEFGENERIC is clear to me. But what about "ensure-generic-function".
> It is defined in ANSI CL, but nowhere it says how to create
> and get method combination objects.
> Hmm, still I don't understand why there isn't a FIND-METHOD-COMBINATION
> (maybe also accepting nil as the argument for the generic function).
> I want to feed ENDURE-GENERIC-FUNCTION the right arguments,
> but how do I get these (the method combination metaobject)
> in ANSI CL? If you look at the HyperSpec you see that the
> explanation for the method-combination option has no
> link into the glossary. Seems like this is left for future work...

I think this is one of the places where the boundary between the bits
of CLOS that made it in and those that didn't is really inconsistent.
I frequently find myself getting annoyed that there isn't a complete
functional layer that underlies the macro layer (my particular
annoyance being the absence of ENSURE-CLASS, so you can't
programatically mix classes portably).  

This needs to be sorted out I think: perhaps someone should go through
things and work out what needs to be put in, without putting the whole
of AMOP in, which i suspect is unimplementable efficiently (especially
things like difficulty of SLOT-VALUE optimisation if you believe
AMOP).

--tim



Sun, 01 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Distributed objects vs. generic functions and multi-methods

2. Distributed objects vs. generic functions and multi-methods

3. Generic Functions vs. CLOS Methods

4. Inspecting the methods associated to a generic function

5. what is the equivalent function or combination of functions for the following ASYST code

6. Method : what to ensure after creation ?

7. using rescue/ensure in methods

8. Another take on ensuring right args to methods

9. Q: Ensuring Presence of Method Implementation? (Newbie)

10. How to ensure that a method is compiled?

11. method combinations in dylan

12. A method combination can depend on what?

 

 
Powered by phpBB® Forum Software