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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Bounded String question Date: Tue, 8 Mar 2016 19:18:00 -0600 Organization: JSA Research & Innovation Message-ID: References: <7ba56b33-28d4-42d2-8b9b-5ad9f5beab8b@googlegroups.com> <87io597447.fsf@theworld.com> <87egfw7dnm.fsf@theworld.com> <56dc7e22$0$19749$426a34cc@news.free.fr> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1457486281 24057 24.196.82.226 (9 Mar 2016 01:18:01 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 9 Mar 2016 01:18:01 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:29708 Date: 2016-03-08T19:18:00-06:00 List-Id: "Jeffrey R. Carter" wrote in message news:nbl50v$8qq$1@dont-email.me... > On 03/07/2016 04:16 PM, Randy Brukardt wrote: >> "Xavier Petit" wrote in message >> news:56dc7e22$0$19749$426a34cc@news.free.fr... >> >> I don't know if this is relevant... >> >>> procedure Test_Bounded_String is >>> package Bounded_String is >>> type T (Max_Length : Natural := 100) is limited private; >> >> ...but a type like this can be completed with a non-limited type. That >> might >> prevent the compiler from applying a limited-only optimization. (Another >> way >> to say it is that this type is not inherently limited; non-limited views >> can >> exist of such types, and a non-limited view would need an >> allocate-the-max >> strategy [or a non-contiguous object].) > > The compiler knows the full type (which is limited) when it compiles the > variable declaration and its associated elaboration code. Would it not be > able > to use that information? I'd be speculating to say anything about someone else's compiler. (One thing that we've all learned from the ARG is that what seems natural to one compiler implementer can require some amazingly twisted implementation in some other compiler. Best to never assume anything about some other compiler.) But I will say that it would depend on how the compiler handles objects. For Janus/Ada, it is the type, not the object, that determines the memory management strategy, so we have to tie that down fairly early. And, in any case, the presence of a partial view subtly changes the semantics of a type. (That's was added in Ada 2005 because the Ada 95 rule had the unpleasant effect of making the details of the full type relevant to the usage of the objects in some cases. It's rather a rather messy rule but it was added to preserve the notion that all you need to know about is the private type. (In Ada 95, you could get Constraint_Error when assigning two objects of a type with no visible discriminants. Yuck.) So those rules as well might cause a problem. Randy.