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-Thread: a07f3367d7,5d624451bcaff335 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Null Range in Unconstrasined Array Date: Wed, 09 Sep 2009 09:00:39 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <76a9c14b-c573-4fd4-bbd8-7ab3bd078d79@j9g2000prh.googlegroups.com> <68f49a20-2142-46ee-bed8-e5b3cad398e0@l35g2000pra.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1252501240 31124 192.74.137.71 (9 Sep 2009 13:00:40 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 9 Sep 2009 13:00:40 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:qDsTPqQ4HKWxDizHGCVSNPtR0V0= Xref: g2news2.google.com comp.lang.ada:8248 Date: 2009-09-09T09:00:39-04:00 List-Id: Stephen Leake writes: > Adam Beneschan writes: > >> To elaborate on this a bit further: Suppose you define a record type >> for reading a file with Ada.Direct_IO, that looks something like this: >> >> type Employee_Data is record >> Name : String (1 .. 50); >> Address1 : String (1 .. 40); >> Address2 : String (1 .. 40); >> City : String (1 .. 30); >> State : String (1 .. 2); >> ... >> end record; >> >> (Reminds me of my COBOL programming days...) Anyway, it would be very >> unexpected for the compiler to put two extra integers in the record >> for each of these strings, and it would mess up your file I/O. > > If you expect the layout of this record to match your file, you must > provide a representation clause. Good idea. > It _could_ depend on whether there's a pragma Pack, or a > representation clause, for the record. In the absence of such, I would > expect the compiler to treat these components the same way it treats > separate objects. Yes. >...Which means I would expect the bounds to be stored > with the object. Most compilers, including GNAT, will not store the bounds with the object (whether it's a component or a standalone object). Think about an array of a million of those records: you don't want 1,000,000 copies of the number 50 stored at run time. That number is known to the compiler, and can be plugged in wherever needed (e.g. when you say "for X in A(Y).Name'Range loop", the compiler knows that's just "for X in 1..50 loop". > But that's just my expectations; compilers are free to do whatever they > want, as long as it meets the standard. Right. - Bob