Re: [CLOS] Ensuring a method exists



Pascal Costanza wrote:
Wade Humeniuk wrote:
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.


That is not what I meant. In a dynamic environment
(defmethod foo ((a derived) (b derived)) ...) never has-to exist, or..
may exist then be undefined/redefined, or.. foo is redefined
to be a simple defun. Why does a program need
functional completeness? Why cannot it be left unfinished?

The OP's motives are not clear to me (besides the possible
motive of mimicking C++ virtual classes).
If the intention is that specialzed foos have to be defined
for all subclasses , then this requirement can be overridden
by some smart-ass doing

(defmethod foo ((a derived) (b derived))
(call-next-method))

Follows the letter of the law but not the intention.

Or...

(defmethod foo :around ((a derived) (b derived))
(foo-on-you a b))

Wade
.