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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,43aafc250d42730f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-07 14:01:19 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!144.212.100.101!newsfeed.mathworks.com!portc03.blue.aol.com!newsfeed.skycache.com!Cidera!typhoon.sonic.net!uunet!sac.uu.net!usenet.rational.com!not-for-mail From: "Mark Lundquist" Newsgroups: comp.lang.ada Subject: Re: controlled type in generic package? Date: Wed, 7 Feb 2001 13:57:17 -0800 Organization: Rational Software Message-ID: <95sgd9$ncg$1@usenet.rational.com> References: <3A7FDA9A.C667090F@stn-atlas.de> <95q19j$9d$1@usenet.rational.com> NNTP-Posting-Host: ext-4254.rational.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: supernews.google.com comp.lang.ada:4953 Date: 2001-02-07T13:57:17-08:00 List-Id: Lutz Donnerhacke wrote in message news:slrn9827l8.ml.lutz@taranis.iks-jena.de... > * Mark Lundquist wrote: > >The compilation error that was reported would have been due to the > >instantiation. The instantiation is a copy of the generic template, so you > >can't instantiate a generic that does something that would be illegal to do > >in the same place if it weren't in a generic :-). In this case, that > >something is to declare a type extension that's statically deeper than the > >parent. > > I don't understand the reason, but will keep it in mind, until I came across > this situation. OK, here's the reason: Suppose you have type T is tagged record . . and procedure P (X : access T'Class); -- (or a parameter of a named access type) Now suppose in a nested scope we say type D is new T with record . . If we have an object of type D, we can pass a pointer to it in a call to P. But maybe P does something squirrely with this pointer, like saving it on a list. Once the scope of D goes away, so have all objects of type D, so that pointer is now dangling. The result: The Kind Of Error That Is Not Supposed To Happen To An Ada Program :-) :-) I think Bob Duff's "limited access" proposal would fix this. I really like that proposal. -- mark