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

Re: simple method dispatch question



This doesn't work in Dylan or C++.  Both Dylan generic functions and C++
virtual methods dispatch on the runtime type of the object, not the static
type.

What you want to do was easy to do in Flavors, where you could specify that
your generic function used PROGN method combination, which meant that you
called _all_ the applicable methods, not just the most applicable.  But this
feature was discarded Dylan (and CLOS?) as being too baroque.

Another approach (which I think may be used in DUIM?) is to write a macro
for defining your methods that automatically inserts a next-method() call.

Rob Myers robm@h2g2.com on  2000-11-10 12:00 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? :-)
> 
> - Rob.
> 
> "Jason Trenouth" <jason@harlequin.co.uk> wrote in message
> news:b38o0tsl43hqe8np8kpbt9v0c9iar8vtap@4ax.com...
>> On Fri, 10 Nov 2000 11:15:01 -0500 (EST), johncwhi@my-deja.com wrote:
>> 
>>> Is it possible to force calling a particular instance of a generic
>>> function-- a super class' instance--when you have an object which
>>> inherits from two different super classes?
>> 
>> Basically no. You have to do through an explicit protocol:
> 
> 
> 
> 
> 



Follow-Ups: References: