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: Tue, 09 Feb 2010 09:45:26 -0500
Date: 2010-02-09T09:45:26-05:00	[thread overview]
Message-ID: <wcc7hqmo4c9.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3e1a4234-95ef-4e77-a87d-1bc6e560fe7f@z10g2000prh.googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Feb 8, 1:20�pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
>> And anyway, slices as L-values don't really work:
>>
>> � � X : String := "abc";
>>
>> � � X (2..2) := "xxx";
>>
>> One might expect X = "axxxc",
>
> One *what*??  One Perl programmer???
>
> Really, I don't expect that anyone who understands Ada is going to get
> this wrong.

Yes, of course.  My point is just that if you want to replace
a slice of a string with another string, you can't do it,
unless they happen to be the same size.  I agree most Ada
programmers understand that -- and if they don't, they'll
find out pretty quickly.

Or you can do a lot of horsing around with unbounded strings.
And there, you don't get any special slice syntax, just
subprograms.  I really hate the fact that you don't get
normal string syntax for unbounded strings, but if I had
to choose which such syntax I want the most, I'd choose
string literals and indexing long before I'd choose slices.

>...Programmers who haven't yet learned the language may not
> understand it, but that's probably true of *any* feature of the
> language, except perhaps for this:
>
> procedure Main_Program is
> begin
>    null;
> end Main_Program;
>
> Like most of the other posters here, I find slices very useful.

Yeah, everybody in this thread is singing the praises of slices.
But nobody's taken my challenge: write down several features
of Ada that you'd rather do without than slices.  In other
words, fill in the blank:

    I'd rather do without ________ than do without slices.

I can think of some:  Entry families.  Line/column counting in Text_IO.

But you won't find me putting "packages" or "case statements"
or "parameter passing" in that blank!

My point is: the benefit of slices (over plain old procedure calls)
has to be relative to other features.  Just saying "slices are
useful" doesn't contradict anything I said -- I agree they're
useful.

>...Also,
> I don't have a particular problem using them, on both sides of ":=".
> I don't think I get them wrong any more than I get anything else
> wrong.

Well, what started this was my claim that all strings, including slices,
ought to start at 1.  I've seen huge numbers of bugs where this was
incorrectly assumed.  And it's nasty, because the vast majority of strings
DO start at one, so you don't notice the bug right away.  You notice it
a year later when somebody passes a slice to a procedure that always
worked before.

- Bob



  reply	other threads:[~2010-02-09 14:45 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 [this message]
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
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