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!feeder.eternal-september.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Is this actually possible? Date: Wed, 11 Dec 2019 20:00:58 -0600 Organization: JSA Research & Innovation Message-ID: References: <36d45c82-2a6b-4c60-baeb-1a4aef5189c7@googlegroups.com> <69c7677b-4aec-4db2-b240-de6b69f762b9@googlegroups.com> Injection-Date: Thu, 12 Dec 2019 02:00:59 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="23816"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:57713 Date: 2019-12-11T20:00:58-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:qsrncj$u95$1@gioia.aioe.org... > On 2019-12-11 22:12, Lucretia wrote: ... > Why? You must know all variants in order to compute the array element > size. In Ada you cannot have it either: > > type Not_an_Array is array (Positive range <>) of T'Class; > > This is illegal. This is the purpose of the Bounded_Indefinite_Holders, because this is a useful thing to do sometimes. package My_Holders is new Ada.Containers.Bounded_Indefinite_Holders (T'Class, 100); type An_Array is array (Positive range <>) of My_Holders.Holder; Here, a Holder will hold up to 100 storage units. If some extension of T'Class is bigger than that, setting the holder to a value of that extension raises Program_Error. (As with most checks, this one can be suppressed, and if it would fail and is suppressed, the program is erroneous - presumably some other object memory would be overwritten. So don't do that. ;-) This is probably one of the best (and simplest) ideas of Ada 202x. Thanks to Niklas Holsti for the original idea (although I think the actual resulting package isn't much like Niklas' original idea). Randy.