From: AdaMagica on 9 Feb 2010 04:14 > Now, I am sure someone will tell: "but that doesn't go as far as > multidimensional arrays...". True. Look at the syntax for Fortran > slices, and you'll see that the cure would be > worth than the disease. ~~~~~~ I think you mean the opposite: worse
From: Jean-Pierre Rosen on 9 Feb 2010 06:19 AdaMagica a �crit : >> Now, I am sure someone will tell: "but that doesn't go as far as >> multidimensional arrays...". True. Look at the syntax for Fortran >> slices, and you'll see that the cure would be >> worth than the disease. > ~~~~~~ > I think you mean the opposite: worse Sure. Certainly no Freudian slip here! -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr
From: Robert A Duff on 9 Feb 2010 09:26 Pascal Obry <pascal(a)obry.net> writes: > I beg to disagree strongly to that too :) > > I have lot of code like this one: > > S (A .. B) := R (C .. D); > > or > > S (A .. B) := V; I just did some searching in the GNAT sources. About a million lines of code. About 7000 slices. About 1500 slices on the left of ":=". Warning: this is a crude search -- I probably have both false positives and false negatives. I must admit, these are higher numbers than I expected. Almost all of them look like strings, at a quick glance. > I would say that slices are really what make life easier in Ada compared > to other languages in many ways. OK, but I'm not comparing them to other languages. I'm comparing them to other features of Ada (or other features that I'd like to see in Ada). - Bob
From: Robert A Duff on 9 Feb 2010 09:29 tmoran(a)acm.org writes: >>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. > > package Int_IO is new Ada.Text_IO.Integer_IO(Integer); > ... > Last := Line'first-1; > for i in V'range loop > Integer_IO.Get(Line(Last+1 .. Line'last), V(i), Last); > end loop; Interesting example. Thanks! I'd still prefer all strings start at 1, and I'd do parsing of a text stream of integers in a different way (keep track of current position without using slices at all). - Bob
From: Robert A Duff on 9 Feb 2010 09:33
"(see below)" <yaldnif.w(a)blueyonder.co.uk> writes: > On 08/02/2010 21:20, in article wccd40fpgpu.fsf(a)shell01.TheWorld.com, > "Robert A Duff" <bobduff(a)shell01.TheWorld.com> wrote: > >> It's trivial if you only want slices as R-values. >> And anyway, slices as L-values don't really work: > > I can't agree. I have this code: > > procedure FFT_to_HWT (FFTCs : in complex_array; ... > HWT_tree : out complex_array; ...) is > ... > iFFTCs : complex_array (1..f(FFTCs'length)); > begin > ... > iFFTCs(1..nr_bins) := FFTCs(first_bin..last_bin); > iFFTCs(nr_bins+1..iFFT_size) := (others => (0.0,0.0)); > inverse_FFT(iFFTCs(1..iFFT_size)); > ... > HWT_tree(next_HWTC..next_HWTC+iFFT_size-1) := iFFTCs(1..iFFT_size); > ... > end FFT_to_HWT; > > I think that using slices as L-values as well as R-values helps to make this > a lot clearer than it otherwise would be, and probably faster as well. "Clearer"? Yes, I agree. "A lot clearer"? I don't know -- something like: Copy_Slice(iFFTCs, ...); doesn't seem so horrible. - Bob |