[Prev][Next][Index][Thread]

Re: simple method dispatch question



On Fri, 10 Nov 2000 12:45:01 -0500 (EST), johncwhi@my-deja.com wrote:

> I like your second technique better than the first.  I wonder which
> would be more efficient.
> 
> Here's another gotcha in this whole thing though:  You probably wouldn't
> know that you need to have the print-as protocol for printing derived
> classes until (of course) you created the derived classes.  A derived
> class might not seem necessary during initial design phases. This could
> force some redesign (is the $64 word "refactoring") in Dylan which might
> be avoided in C++.

Refactoring isn't forced in Dylan. Something like this would probably work (
but I haven't tested it ).

define constant print-as-test =
  find-method( print, list( <test> ) ); // or somesuch

define method print ( x :: <mixed-test> )
  print-as-test( x );
end method print;

The need to call a specific method without giving it a distinct name is just
poor design.

__Jason


References: