comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Copying rows in a two dimensional array.
Date: Mon, 1 Feb 2010 18:07:20 -0600
Date: 2010-02-01T18:07:20-06:00	[thread overview]
Message-ID: <hk7qbp$p7g$1@munin.nbi.dk> (raw)
In-Reply-To: ed36036c-8318-4f27-aaae-5329a8bfc83d@t31g2000prh.googlegroups.com

I presume this was because the elements in question are not necessarily 
adjacent. As such the code ends up being exactly the same (or sometimes 
worse) than an explicitly coded loop.

And honestly, I don't see any real advantage to slices in terms of safety 
(given that indexes are checked for in-range, as they are in Ada). I make 
just as many mistakes with slices as I do with loops -- I find it hard to 
figure out the ends of the two slices for assignment (which have to be the 
same length - mine only are about 1/2 of the time); it's about the same 
difficulty as figuring out the offset amount when writing a loop to copy 
items. So I see it as a wash, other than that a one-dimensional slice can 
generate much better code (using a direct memory-memory move the for entire 
amount). The safety win comes for whole object assignments, not parts.

                           Randy.

"Jerry" <lanceboyle@qwest.net> wrote in message 
news:ed36036c-8318-4f27-aaae-5329a8bfc83d@t31g2000prh.googlegroups.com...
> I've never understood why Ada does not allow slicing in
> multidimensional arrays. What are the safety issues involved? And how
> is it safe to force the programmer into ad hoc methods?
>
> Jerry 





  reply	other threads:[~2010-02-02  0:07 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
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 [this message]
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