Re: [CLOS] Ensuring a method exists
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Wed, 27 Sep 2006 20:48:44 +0200
Wade Humeniuk wrote:
Didier Verna wrote:Hi !
Suppose I have:
(defgeneric foo (a b) ...)
(defclass base () ...)
(defmethod foo ((a base) (b base)) ...)
I'd like to ensure that if somebody writes a derived class:
(defclass derived (base) ...)
she also provides a method for this class:
(defmethod foo ((a derived) (b derived)) ...)
If someone defines the DERIVED class, how long do you give them
to define the foo method? The first time foo is called with
and instance of derived?? Or can they use the inherited method
until they determine how they need to specialize on derived.
What you are asking flies in the face of interactive dynamic
development. You need the fluidity/imprecision during development.
Maybe when "everything is finished" then you can run a consistency
check to see that everything is "proper".
It seems to me that the latest possible stage to check this is when the applicable methods for some generic function call are determined. You can then just check whether the most specific primary method is specialized on exactly the classes of the arguments. This can be done in methods on compute-applicable-methods and compute-applicable-methods-using-classes.
It's also possible to do this in a user-defined method combination, but then you can only do the check as part of the execution of the effective method, whereas in c-a-m and c-a-m-u-c, once the check succeeds, it won't be checked again in subsequent calls of arguments of the same classes.
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: [CLOS] Ensuring a method exists
- From: Wade Humeniuk
- Re: [CLOS] Ensuring a method exists
- References:
- [CLOS] Ensuring a method exists
- From: Didier Verna
- Re: [CLOS] Ensuring a method exists
- From: Wade Humeniuk
- [CLOS] Ensuring a method exists
- Prev by Date: Re: [CLOS] Ensuring a method exists
- Next by Date: Re: [CLOS] Ensuring a method exists
- Previous by thread: Re: [CLOS] Ensuring a method exists
- Next by thread: Re: [CLOS] Ensuring a method exists
- Index(es):
Relevant Pages
|