comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Dynamic redispatching
Date: 2000/01/19
Date: 2000-01-19T00:00:00+00:00	[thread overview]
Message-ID: <864ir0$5up$1@nnrp1.deja.com> (raw)
In-Reply-To: m3hfgazg42.fsf@baka.infomatch.bc.ca

In article <m3hfgazg42.fsf@baka.infomatch.bc.ca>,
  Ray Blaak <blaak@infomatch.com> wrote:
> Perhaps this would work:
>
>    Item.all := P1.Dispatch;

Yes, that would work for the example I gave. However, it won't for this
example (which is closer to what I'm trying to do):

package P1 is

   type Instance is tagged null record;
   subtype Class is Instance'Class;
   type Handle is access all Class;

   function Dispatch return Instance;
   function Main_Dispatcher return Class;

   type Dispatcher_Routine is access function return Class;
   Default_Dispatcher : Dispatcher_Routine := Main_Dispatcher'access;
end P1;

with P1;
with P2;

procedure Test is

   Item : P1.Handle := new P2.Instance;
begin
   Item.all := P1.Default_Dispatcher.all;
end Test;

IOW: I want to be able to supply function pointers that dispatch. Making
the type an "access function return Instance" doesn't work, because
P2.Dispatch'access isn't compatable with that type (P1.Instance and
P2.Instance are different types). So I tried making it classwide. That
works, except that the classwide function for some reason can't
redispatch to the appropriate primitive function.

Is this just a limitation of functions in Ada? Would changing everything
to procedures with "out" parameters solve the problem?

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-01-19  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-18  0:00 Dynamic redispatching Ted Dennison
2000-01-18  0:00 ` Ray Blaak
2000-01-19  0:00   ` Ted Dennison [this message]
2000-01-20  0:00     ` Tucker Taft
2000-01-20  0:00       ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox