comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Copying rows in a two dimensional array.
Date: Mon, 08 Feb 2010 16:14:30 -0500
Date: 2010-02-08T16:14:30-05:00	[thread overview]
Message-ID: <wcchbprpgzt.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: hkpmk0$7kl$1@speranza.aioe.org

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



  reply	other threads:[~2010-02-08 21:14 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01  2:11 Copying rows in a two dimensional array Peter C. Chapin
2010-02-01  4:42 ` Jeffrey R. Carter
2010-02-01  6:55 ` Niklas Holsti
2010-02-01 23:36   ` Peter C. Chapin
2010-02-04  4:27   ` Hibou57 (Yannick Duchêne)
2010-02-01  8:37 ` Dmitry A. Kazakov
2010-02-02  0:11   ` Randy Brukardt
2010-02-07 16:13     ` Robert A Duff
2010-02-08  6:30       ` tmoran
2010-02-08 13:15         ` Robert A Duff
2010-02-08 13:45           ` Dmitry A. Kazakov
2010-02-08 21:20             ` Robert A Duff
2010-02-08 23:26               ` (see below)
2010-02-09  0:36                 ` Randy Brukardt
2010-02-09  1:03                   ` (see below)
2010-02-09  7:11                   ` Pascal Obry
2010-02-09  8:14                     ` AdaMagica
2010-02-09 14:33                 ` Robert A Duff
2010-02-09  1:05               ` Adam Beneschan
2010-02-09 14:45                 ` Robert A Duff
2010-02-09 18:50                   ` tmoran
2010-02-09 19:51                   ` Pascal Obry
2010-02-09 23:03                     ` Robert A Duff
2010-02-08 18:53           ` tmoran
2010-02-08 21:14             ` Robert A Duff [this message]
2010-02-08 21:29               ` Pascal Obry
2010-02-09  8:56                 ` Jean-Pierre Rosen
2010-02-09  9:14                   ` AdaMagica
2010-02-09 11:19                     ` Jean-Pierre Rosen
2010-02-09 14:26                 ` Robert A Duff
2010-02-09  6:34               ` tmoran
2010-02-09 14:29                 ` Robert A Duff
2010-02-09 18:49                   ` tmoran
2010-02-09 22:58                     ` Robert A Duff
2010-02-01 22:10 ` Jerry
2010-02-02  0:07   ` Randy Brukardt
2010-02-02  8:52   ` Jean-Pierre Rosen
2010-02-02 22:23     ` Jerry
2010-02-03  1:24       ` Adam Beneschan
2010-02-04  4:42     ` Hibou57 (Yannick Duchêne)
2010-02-14  0:42     ` jonathan
2010-02-14  1:54       ` Hibou57 (Yannick Duchêne)
2010-02-14 16:16         ` jonathan
2010-03-22  8:56           ` Ole-Hjalmar Kristensen
2010-02-16  6:51     ` David Thompson
2010-02-04  4:13 ` Hibou57 (Yannick Duchêne)
2010-02-04  9:10   ` Dmitry A. Kazakov
2010-02-04  9:23     ` Hibou57 (Yannick Duchêne)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox