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: 103376,5b3aa4bc9027f04e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.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: Unconstrained Arrays Date: Wed, 25 Mar 2009 18:30:23 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> <0caa9cf8-0620-4544-9b2c-2c9f24142b7f@v23g2000pro.googlegroups.com> <386b0e00-a1c6-4c5f-adf7-89b8543d0e2d@c11g2000yqj.googlegroups.com> <46281cbb-2804-41e8-87a0-251c9060d4d1@c36g2000yqn.googlegroups.com> <4c7128dd-085c-48b0-948f-401fcd64c2a4@c36g2000yqn.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1238020223 28015 192.74.137.71 (25 Mar 2009 22:30:23 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 25 Mar 2009 22:30:23 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:E0MHFvk7WO/mCCyT4uBtMOkUw4o= Xref: g2news1.google.com comp.lang.ada:4319 Date: 2009-03-25T18:30:23-04:00 List-Id: sjw writes: > That makes so much sense! I think my brain freezes when I see the > compiler quoting rules about statically matching, so I just remember > the first 2 lines of the message (as you say, pretty explicit) and > pass over the reason why in the last 2 lines. After all, GNAT is much > more likely to be right than I am. Well, GNAT is right in the sense that it obeys the Ada RM on this point. But some people (including some of the folks who wrote GNAT) think the language designers were wrong on this point. It's an efficiency issue. You can certainly come up with cases that make a big difference: subtype S is String (1..4); type A is array (Positive range <>) of aliased S; X : A (1..1_000_000); type S_Ref is access all S; An object of subtype S is likely 4 bytes without dope, 12 bytes with dope. Removing this restriction from the language would triple the size of X from 4 million bytes to 12 million. If you only wanted to point at components of X from objects of type S_Ref, (as opposed to some "access all String" type) then that would be annoying (why store 1 million copies of the compile-time-known values 1 and 4?). Memory is not cheap -- using more memory tends to cause cache misses. On the other hand, the restriction is confusing, and not strictly necessary. - Bob