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,bf03d731a6ef511f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!news-out.readnews.com!transit3.readnews.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Copying rows in a two dimensional array. Date: Sun, 07 Feb 2010 11:13:19 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4b6637a1$0$4586$4d3efbfe@news.sover.net> <178rg3rch8qdu$.13cgkywb09x3p.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1265559187 3368 192.74.137.71 (7 Feb 2010 16:13:07 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 7 Feb 2010 16:13:07 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:imoknwXQygi6VOnANgCknHGZJZ0= Xref: g2news1.google.com comp.lang.ada:8952 Date: 2010-02-07T11:13:19-05:00 List-Id: "Randy Brukardt" writes: > "Dmitry A. Kazakov" wrote in message > news:178rg3rch8qdu$.13cgkywb09x3p.dlg@40tude.net... >> On Sun, 31 Jan 2010 21:11:12 -0500, Peter C. Chapin wrote: >> >>> So I thought, "Perhaps A needs to be an array of arrays." >>> >>> type Matrix is array(Positive range <>) of WHAT_EXACTLY? >>> >>> Apparently the component type of an array needs to be fully constrained >>> (which >>> again makes sense) >> >> Not really. Arrays should have been allowed to have discriminants. That >> was >> missed in the language design. > > Early Ada 9x had discriminants for arrays. The capability got dropped when > lots of "nice-to-have" features got dropped from Ada 95. Such "array" types > have to be implemented as discriminant dependent records anyway; there is no > real hope of performance improvement from them, but a lot of implementation > complication. (I recall I was one of the stronger opponents of this feature, > mostly for implementation cost/benefit reasons.) > > So it is completely wrong to say that "this was missed in the language > design". The correct statement is that "this was explicitly rejected in the > language design". It was missed in the design of Ada 83. By the time of Ada 9X, it was too late. Sad. If Ada 83 had had discriminated arrays, it would have been a (slightly) simpler language. And they're not hard to implement, if you know about them ahead of time. They may be hard to add to an existing Ada 83 compiler that was designed based on the rules of Ada 83. That's true in general -- it's a lot easier to build an Ada 95 compiler, than it is to build an Ada 83 compiler and then modify it to support Ada 95. Discriminated arrays would be more efficient than Ada's arrays. We would have: type String (Length : Natural) is array (Positive range 1..Length) of Character; This typically shrinks all unknown-length strings by 32 bits, which is significant. (Think about all the memory currently being wasted to store zillions of copies of the number 1.) And it makes bounds checking cheaper because the lower bound is known at compile time. And it would reduce the number of bugs -- all strings would start at 1 (as opposed to the current sitation, where 99.99% of all strings start at 1, and remaining 0.01% are bugs waiting to happen). And it would simplify the language (no need for the "range <>" syntax, no need for the 'First and 'Last attributes of arrays, no need for separate rules about array bounds and discriminants (which are almost, but not quite, the same), etc). Adding it to Ada 95 would NOT simplify, because we'd have to keep all those now-useless features for compatibility. - Bob