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

Re: simple method dispatch question



On Fri, 10 Nov 2000 12:00:01 -0500 (EST), "Rob Myers" <robm@h2g2.com> wrote:

> Would:
> 
> define method maybe-works( obj :: <test2> )
>     maybe-works( as( <test1>, obj ) );
>     maybe-works( as( <test>, obj ) );
> end method;
> 
> work? Assuming test1 and test are superclasses of test2, won't obj just get
> cast down? Or is this C++ rather than Dylan? :-)

You must be thinking of C++ rather than Dylan.

Ultimately, it depends on what "as" methods have been written, but by default
"as" will probably just return the value of obj since both:

	instance?( obj, <test1> )
and	instance?( obj, <test> )

are already true. In any case "as" would have to allocate some wrapper or
replacement object to control the dispatch of "maybe-works" which is
undesirable.

__Jason


Follow-Ups: References: