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 10:53:08 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!easynews!cyclone.swbell.net!nnrp1.sbc.net.POSTED!not-for-mail From: "Pat Rogers" Newsgroups: comp.lang.ada References: <3A7FDA9A.C667090F@stn-atlas.de> <95p2ab$463$1@nnrp1.deja.com> <95q1fa$9e$1@usenet.rational.com> <95rpj5$gq7$1@nnrp1.deja.com> Subject: Re: controlled type in generic package? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Wed, 7 Feb 2001 12:52:55 -0600 NNTP-Posting-Host: 208.191.184.67 X-Complaints-To: abuse@swbell.net X-Trace: nnrp1.sbc.net 981571981 208.191.184.67 (Wed, 07 Feb 2001 12:53:01 CST) NNTP-Posting-Date: Wed, 07 Feb 2001 12:53:01 CST Organization: SBC Internet Services Xref: supernews.google.com comp.lang.ada:4937 Date: 2001-02-07T12:52:55-06:00 List-Id: "Ted Dennison" wrote in message news:95rpj5$gq7$1@nnrp1.deja.com... > In article <95q1fa$9e$1@usenet.rational.com>, > "Mark Lundquist" wrote: > > > > Ted Dennison wrote in message > > > Also, any instantiations of this generic will have to be done at the > > > library level, since Limited_Controlled is declared at the library > > > level, and types can't be declared at a lower level of scope than > > > their parent types. > ... > > > (As a user, I hate that rule.) > > > > Do you hate it as much as what might happen if it weren't for the > > rule? :-) > > 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. It is really very similar to the issue of an access value designating a declared (aliased, on the stack) object. For example, one could have an access-to-classwide value designating an allocated value of a type derived within a nested declarative region. When that region "goes away", the type, and hence, the primitive operations go away, and you don't want to try to dispatch to them using that dangling pointer. Consider: package Graphics is type Shape is tagged record ... end record; type Any_Shape is access Shape'Class; procedure Dispatch( O : in Shape ); end Graphics; with Graphics; use Graphics; procedure Illegal_Demo is Global : Any_Shape; procedure Bogus is package Shapes is type Circle is new Shape with ... procedure Dispatch( C : in Circle ); end Shapes; package body Shapes is procedure Dispatch( C : in Circle ) is begin ... end Dispatch; end Shapes; begin Global := new Shapes.Circle; end Bogus; begin Bogus; Dispatch( Global.all ); end Illegal_Demo; Hoe this helps... --- Patrick Rogers Consulting and Training in: http://www.classwide.com Real-Time/OO Languages progers@classwide.com Hard Deadline Schedulability Analysis (281)648-3165 Software Fault Tolerance