From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,68b702bd2264cada X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Dynamic redispatching Date: 2000/01/19 Message-ID: <864ir0$5up$1@nnrp1.deja.com>#1/1 X-Deja-AN: 574686874 References: <862gtg$meu$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x29.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Jan 19 14:48:06 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 2000-01-19T00:00:00+00:00 List-Id: In article , Ray Blaak 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.