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-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!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: Mon, 08 Feb 2010 16:14:30 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1265663657 5947 192.74.137.71 (8 Feb 2010 21:14:17 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 8 Feb 2010 21:14:17 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:doRo7deMz5QpXeRRidvgK6f66+I= Xref: g2news1.google.com comp.lang.ada:8997 Date: 2010-02-08T16:14:30-05:00 List-Id: tmoran@acm.org writes: >> In Ada, if you do "P(X(5..10));" procedure P can see that the >> lower bound is 5. That's a break in the abstraction -- P shouldn't >> know or care where the string came from. > For many, but not all, P. Can you give an example where P should know that its String parameter came from a slice, and should know the lower bound of that slice? I can't think of any off the top of my head -- it just seems like a fundamentally broken abstraction if you care about the lower bound of a string. Just to be clear: I'm talking about Strings here, and other array types that have a natural lower bound (usually 1, sometimes 0). I'm not necessarily talking about all array types -- the discriminated arrays feature I am imagining would allow the programmer to choose whether to fix the lower bound at a particular value. Or the upper bound, or both, or neither. >> Actually, slices are one of the least useful features of Ada. >> I wouldn't mind (much) if they didn't exist in the first place. > Wow, I beg to strongly differ. OK, I guess I shouldn't have said "least useful". I should have said that it's easy enough to work around the lack of this feature. In my experience, almost all slices are of type String. And almost all are R-values. So a function: function Slice (S: String; First: Positive; Last: Natural) return String; would do the trick, at some small efficiency cost. (Note that we tolerate this interface in the case of unbounded strings.) Think about it this way: Name some features of Ada that you would rather do without than slices. I can think of a few, but not many. It would be much more painful to do without, say, case statements than slices. Or think about it this way: Name some features that Ada does not have that you'd be willing to trade slices for. For example, I'd love to be able to fix the lower bound of an array type, and I'd happily do without slices for that. ;-) And if you want a really useful/powerful slice facility, look to Fortran! - Bob