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,db88d0444fafe8eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Surprise in array concatenation Date: 05 Sep 2005 18:13:16 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1125610942.747981.280770@f14g2000cwb.googlegroups.com> <1125935610.797293.40550@g43g2000cwa.googlegroups.com> <1125942434.046551.206180@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1125958396 13893 192.74.137.71 (5 Sep 2005 22:13:16 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 5 Sep 2005 22:13:16 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:4455 Date: 2005-09-05T18:13:16-04:00 List-Id: "jimmaureenrogers@worldnet.att.net" writes: >...Concatenating array A whose indices represent > the null set with array B whose indices represent some non-null set > should always result in an array whose indices are a non-null set. Agreed. > Moreover, the most efficient and logical merging of the two sets > results in a set idenitcal to the indices of B. I don't agree that's most logical, but I suppose that's somewhat a matter of taste. But the Ada rule is _certainly_ not the "most efficient"! If all Strings start at 1, then we reduce the size of the array dope by 4 bytes. If the average String length in your program is, say, 20 bytes, you're saving 4 bytes for every 24, or about 17% of the memory use, which is substantial. Saving memory generally speed up programs due to cache effects. It's really annoying to me that the compiler stores zillions of copies of the number 1 in memory (one copy for each String object), just because some oddball String _might_ start at other than 1. Furthermore, bounds checking would be much faster, because there would be no need to load the lower-bound from memory. Memory loads are often slow on modern machines. Furthermore, consider the code generated for 'Length: In Ada, it's something like: if X'First <= X'Last then X'Last - X'First + 1 else 0 end if; If X'First were known to be always 1, it would be: X'Last If X'First were known to be always 17, it would be: X'Last - 16 These latter are branch-free code sequences. Branches are often slow on modern machines. - Bob