Re: [CLOS] Ensuring a method exists





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.

..., 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...

... 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.

:)

kt

--
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
.



Relevant Pages

  • 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. ... What parameters does a macro function take, and what does it eventually return? ... And your sketch of a solution doesn't yet deal with doing the check only once for each list of specializers. ...
    (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)

Quantcast