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.5 required=5.0 tests=BAYES_00,MSGID_RANDY, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,43aafc250d42730f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-08 01:52:15 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: dmitry6243@my-deja.com Newsgroups: comp.lang.ada Subject: Re: controlled type in generic package? Date: Thu, 08 Feb 2001 09:36:42 GMT Organization: Deja.com Message-ID: <95tpba$9va$1@nnrp1.deja.com> References: <3A7FDA9A.C667090F@stn-atlas.de> <95p2ab$463$1@nnrp1.deja.com> <95q1fa$9e$1@usenet.rational.com> <95rpj5$gq7$1@nnrp1.deja.com> <95sjs9$ral$1@wanadoo.fr> NNTP-Posting-Host: 212.79.194.99 X-Article-Creation-Date: Thu Feb 08 09:36:42 2001 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001108 Netscape6/6.0 X-Http-Proxy: 1.1 x55.deja.com:80 (Squid/1.1.22) for client 212.79.194.99 X-MyDeja-Info: XMYDJUIDdmitry6243 Xref: supernews.google.com comp.lang.ada:4967 Date: 2001-02-08T09:36:42+00:00 List-Id: In article <95sjs9$ral$1@wanadoo.fr>, "Jean-Pierre Rosen" wrote: > > "Ted Dennison" a �crit dans le message news: 95rpj5$gq7$1@nnrp1.deja.com... > > I have to admit I'm a little unclear as to what nasty things could > > happen to me if I were allowed to declare a derived tagged type at a > > lower scope level than their parent type. > OK, let's go: > > package body Pack is > type Parent is tagged ...; > procedure Proc (X : Parent) is ... end Proc; > > type Ptr is access Parent'Class; > V : Ptr; > > procedure P is > type Child is new Parent with...; > procedure Proc (X : Child) is... end Proc; > begin > V := new Child; > end P; > > begin > P; > -- Now, V.all points to an object of type P.Child > -- We can call Proc (V.all) which will result in a dispatching call > to P.Proc, but P is out of scope at this point !!! This is an issue of how dispatch tables are implemented and maintained at run-time. One could imagine a mechanism that would restore the dispatch table, when a derived type goes away. The type tag could be "redirected" to the base type tag, or the table slots corresponding to the overriden methods could be restored etc. What is really nasty, is that the semantic of V.Proc would depend on the context. -- Regards, Dmitry Kazakov Sent via Deja.com http://www.deja.com/