Re: [CLOS] Ensuring a method exists



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

I think I know what you want, if you could be more specific
as what you want to achieve. (is it, I don't trust the programmers
to do the right thing, or, the system is so large I want some
automated check to ease my mind, or, there is a an absolute
technical reason (that I am too daft to see at the moment)).

Wade
.



Relevant Pages

  • Re: [CLOS] Ensuring a method exists
    ... (defgeneric foo (a b) ... (defclass base () ... I'd like to ensure that if somebody writes a derived class: ... to define the foo method? ...
    (comp.lang.lisp)
  • Re: Overriding newbie question.
    ... public virtual int MyMethod ... class Bar: Foo ... The other fundemental thing is this will only work if the method is being called on a derived class object. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: derived class can not access base class protected member?
    ... I am not invoking foo in derived class, the error occurs when I invoke ... void goo() ... Because foois defined as PRIVATE in the base class ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Function Returning a local object???
    ... >>are themselves class objects or worse still objectsof a derived class, ... >>when foo returns such a class by value. ... the compiler will emit code similar to: ... >>(I've read enough to know that the copy constructor is only invloved ...
    (comp.lang.cpp)
  • Re: [CLOS] Ensuring a method exists
    ... (defgeneric foo (a b) ... (defclass base () ... I'd like to ensure that if somebody writes a derived class: ... to define the foo method? ...
    (comp.lang.lisp)