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,fea5f9c57f8bf287 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-20 14:43:50 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3BD1F00D.9EB26E5F@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Discriminants constraining unconstrained array types References: <87g08e9urn.fsf@chiark.greenend.org.uk> <3BD1B6F3.F90883D7@worldnet.att.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 20 Oct 2001 21:43:48 GMT NNTP-Posting-Host: 63.178.187.87 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1003614228 63.178.187.87 (Sat, 20 Oct 2001 14:43:48 PDT) NNTP-Posting-Date: Sat, 20 Oct 2001 14:43:48 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sat, 20 Oct 2001 14:40:05 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:14978 Date: 2001-10-20T21:43:48+00:00 List-Id: James Rogers wrote: > > Matthew Woodcraft wrote: > > > > The following rule appears in the GNAT coding style guide: > > > > | Do not declare discriminated record types where the discriminant is > > | used for constraining an unconstrained array type. (Discriminated > > | records for a variant part are allowed.) > > > The first problems is memory usage. Take the following example: > > type Unconstrained_Type is array(Positive range <>) of Integer; > > type Inadvised_Record_Type (Max : Positive) is record > Buffer : Unconstrained_Type(1..Max); > end record; I am not aware of any compilers that generate unreasonable code for such a construct. They all size objects of such a type based on the actual subtype. A memory problem frequently occurs if the type has a default discriminant and unconstrained objects are created, but the rule goes beyond excluding such types/objects. -- Jeff Carter "Perfidious English mouse-dropping hoarders." Monty Python & the Holy Grail