comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Array Help?
Date: Wed, 7 Mar 2012 17:58:41 -0600
Date: 2012-03-07T17:58:41-06:00	[thread overview]
Message-ID: <jj8snn$8n7$1@munin.nbi.dk> (raw)
In-Reply-To: wccy5rls0hl.fsf@shell01.TheWorld.com

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message 
news:wccy5rls0hl.fsf@shell01.TheWorld.com...
> stefan-lucks@see-the.signature writes:
...
> Sure, slices are useful, and I use them.  But I wouldn't mind too
> much if they didn't exist.  It's trivial to write a Slice function
> that does what "A(F..L)" does.

In Ada 2012, it's not that hard to write a Slice_LValue function that would 
let you assign into A(F..L). It's in fact the key to my half-formed 
Root_String'Class proposal (plus the indexing features already in Ada 2012 - 
the only thing missing is string literals).

> You didn't address my point about l-values.  None of your slices
> above are l-values.  L-value slices cause a lot of implementation
> trouble, and are nearly useless -- the language would be better
> off without them.

I don't buy this at all. I've tried using loops instead of slices to do 
string manipulation (early Janus/Ada didn't have slices), and the results 
had horrific readability and performance. Even today, the optimization of 
slices is much better than the optimization of the supposedly equivalent 
loop (mainly because no optimization is needed to optimize the slice; the 
code is already nearly optimal when created by the Janus/Ada front end). 
Obviously, this could be different on a different Ada compiler, but I'm at 
least a bit skeptical.

>> On the other hand, I agree that the fact that array slices carry their
>> original indices with them is a misfeature of Ada.
>>
>> I would appreciate way to convert ingoing parameters into some standard
>> indexing. For example (inventing a new syntax variant on the fly):
>>
>>   procedure Sort(Items: in out array(generic Positive range <>) of T) is
>
> Interesting idea.

Can't you do this with a type conversion to an appropriate constrained array 
subtype? (Such conversions slide.) I suppose it could be a pain to declare 
such a subtype in front of every call, but it is a trick I've used a some 
cases (usually in wrappers) to force sliding on arguments.

I suppose a more convinient way to force that would be helpful.

                                Randy.





  parent reply	other threads:[~2012-03-07 23:58 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 20:15 Array Help? Will
2012-02-28 20:47 ` Ludovic Brenta
2012-02-28 22:11   ` Simon Wright
2012-02-28 23:09     ` Will
2012-02-29  0:24   ` Adam Beneschan
2012-02-28 20:50 ` Gautier write-only
2012-02-28 21:33 ` Simon Wright
2012-02-29  0:27   ` Adam Beneschan
2012-02-29  8:00     ` Simon Wright
2012-02-29  8:48       ` Simon Wright
2012-02-29  0:22 ` Adam Beneschan
2012-02-29 16:09   ` Robert A Duff
2012-02-29 16:50     ` Ludovic Brenta
2012-02-29 18:24       ` Robert A Duff
2012-02-29 19:45         ` stefan-lucks
2012-02-29 20:45           ` Jeffrey Carter
2012-02-29 21:27             ` stefan-lucks
2012-02-29 23:06           ` Robert A Duff
2012-03-02 13:45             ` stefan-lucks
2012-03-07 23:58             ` Randy Brukardt [this message]
2012-03-08 11:20               ` stefan-lucks
2012-03-09  2:02                 ` Randy Brukardt
2012-03-09  8:48                   ` stefan-lucks
2012-03-09 21:10                     ` Randy Brukardt
2012-03-15  2:55                     ` BrianG
2012-03-15  7:46                       ` stefan-lucks
2012-02-29 20:07         ` Dmitry A. Kazakov
2012-02-29 23:15           ` Robert A Duff
2012-03-01  8:54             ` Dmitry A. Kazakov
2012-03-01 14:06               ` Robert A Duff
2012-02-29 20:47         ` Simon Wright
2012-02-29 22:23           ` Robert A Duff
2012-02-29 23:27             ` Robert A Duff
2012-03-01  0:53               ` Adam Beneschan
2012-03-01  7:16               ` Ludovic Brenta
2012-03-01 14:03                 ` Robert A Duff
2012-03-08  0:11                   ` Randy Brukardt
2012-03-08  0:08               ` Randy Brukardt
2012-02-29 23:30             ` Simon Wright
2012-02-29 18:35     ` Jeffrey Carter
2012-02-29 22:59       ` Robert A Duff
2012-02-29 23:51         ` Jeffrey Carter
2012-03-01  3:03           ` Robert A Duff
2012-02-29 20:40     ` Adam Beneschan
replies disabled

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