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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,fea5f9c57f8bf287 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-20 12:02:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!proxad.net!feeder2-1.proxad.net!news.free.fr!not-for-mail Message-ID: <3BD1CAC0.F5F48B14@free.fr> Date: Sat, 20 Oct 2001 21:04:32 +0200 From: Damien Carbonne X-Mailer: Mozilla 4.75 [fr] (X11; U; Linux 2.2.17-21mdk i686) 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=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Date: 20 Oct 2001 21:02:04 MEST NNTP-Posting-Host: 213.228.10.35 X-Trace: 1003604524 news1-1 859 213.228.10.35 Xref: archiver1.google.com comp.lang.ada:14973 Date: 2001-10-20T21:02:04+02:00 List-Id: James Rogers a �crit : > 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.) > > > > Does anyone know a reason to avoid this feature of the language in > > general, or is it more likely that there's just some issue with the > > runtime or bootstrap behaviour which makes it inadvisable to use in the > > compiler itself? > > I was not involved in the team that wrote this guideline. > > I can explain some of the problems with declaring discriminated > record types used for constraining unconstrained array types. > > 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 think what you explain further is right only if the declaration was: type Inadvised_Record_Type (Max : Positive := 1) is record Buffer : Unconstrained_Type(1..Max); end record; Note: "1" could be replaced by any other valid value. The issue is with default values and declarations without constraint.