Re: [CLOS] Ensuring a method exists
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Wed, 27 Sep 2006 23:33:42 +0200
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/
.
- Follow-Ups:
- Re: Ensuring a method exists
- From: Javier
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: Ensuring a method exists
- References:
- [CLOS] Ensuring a method exists
- From: Didier Verna
- Re: [CLOS] Ensuring a method exists
- From: Lars Rune Nøstdal
- Re: [CLOS] Ensuring a method exists
- From: Didier Verna
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] Ensuring a method exists
- From: Christophe Rhodes
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- Re: [CLOS] Ensuring a method exists
- From: Pascal Costanza
- Re: [CLOS] Ensuring a method exists
- From: Ken Tilton
- [CLOS] Ensuring a method exists
- Prev by Date: Re: [CLOS] Ensuring a method exists
- Next by Date: Re: Aha! moments
- Previous by thread: Re: [CLOS] Ensuring a method exists
- Next by thread: Re: [CLOS] Ensuring a method exists
- Index(es):
Relevant Pages
|
|