Re: [CLOS] Ensuring a method exists



Ken Tilton wrote:

Pascal Costanza wrote:
Ken Tilton wrote:

Now maybe that is what is going on and the OP is just leveraging CLOS as a convenient internal tool to the larger API, but then that is why I suggest going /further/ and hide the CLOS behind some macrology, at which point the OP can enforce anything they want really really easily (instead of staring at AMOP looking for support for something not really OO-able).


Both macros and the CLOS MOP are means to do metaprogramming. The distinction is that macros can be used for compile-time processing of code [1]

??? Hunh? I never use macros for compile-time pro... OK, once.

You _always_ use macros for compile-time processing of code.

Quiz question: What parameters does a macro function take, and what does it eventually return? Joker question: What does the return value of a macro function depend on?

..., while the CLOS MOP is useful for meta-programs that require special actions at runtime. Of course, it is always possible to make macros generate the code that takes care of the runtime issues, but it can be more convenient to rely on the MOP protocols, especially if you want to reuse major parts of the already existing functionality in CLOS.

Didier's example...

He did not have an example. he was literally trying to match the behavior of the C+= compiler in enforcing binary methods. Anyway...

That _is_ an example.

... is actually a good one for the latter because you can delay the check whether methods are "properly" specialized until the latest possible stage, something that is not very easy to achieve with macros.

Nonsense. Macros can expand to code that gets run at load time, which code records (say, in, symbol properties) information to be used by runtime code, such as an around method to check that a method has been defined for the specific types of the arguments.

Or is that not "very easy"? This SuperKenny thing is getting old.

"Easy" is always relative. Defining methods for compute-applicable-methods and compute-applicable-methods-using-classes is easier than what you propose. And your sketch of a solution doesn't yet deal with doing the check only once for each list of specializers.



Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: [CLOS] Ensuring a method exists
    ... Both macros and the CLOS MOP are means to do metaprogramming. ... special actions at runtime. ... Macros can expand to code that gets run at load time, which code records (say, in, symbol properties) information to be used by runtime code, such as an around method to check that a method has been defined for the specific types of the arguments. ...
    (comp.lang.lisp)
  • Re: [CLOS] Ensuring a method exists
    ... Pascal Costanza wrote: ... CLOS as a convenient internal tool to the larger API, but then that is why I suggest going /further/ and hide the CLOS behind some macrology, at which point the OP can enforce anything they want really really easily. ... Both macros and the CLOS MOP are means to do metaprogramming. ... You _always_ use macros for compile-time processing of code. ...
    (comp.lang.lisp)
  • Re: [CLOS] Ensuring a method exists
    ... CLOS as a convenient internal tool to the larger API, but then that is why I suggest going /further/ and hide the CLOS behind some macrology, at which point the OP can enforce anything they want really really easily. ... Both macros and the CLOS MOP are means to do metaprogramming. ... You _always_ use macros for compile-time processing of code. ...
    (comp.lang.lisp)
  • Re: [CLOS] Ensuring a method exists
    ... Both macros and the CLOS MOP are means to do metaprogramming. ... The distinction is that macros can be used for compile-time processing of code, while the CLOS MOP is useful for meta-programs that require special actions at runtime. ... More correctly, "processing of code at macroexpansion time", but for most practical purposes, that's the same as compile time. ...
    (comp.lang.lisp)
  • Re: Default arguments to functions
    ... > Why in the name of God would a compiler not be able to determine from the ... > trying to find a universal way to turn any macro function into a proper ... Macros simply replace text with another equivalent text. ... The compiler does not static check macros, ...
    (comp.lang.cpp)