comp.lang.ada
 help / color / mirror / Atom feed
* improvements for multidimensional arrays ?
@ 2018-05-17  0:32 Mehdi Saada
  2018-05-17  8:06 ` Stefan.Lucks
  0 siblings, 1 reply; 5+ messages in thread
From: Mehdi Saada @ 2018-05-17  0:32 UTC (permalink / raw)


Hello.

Is it likely or not that we see some improvements over multidimensional arrays ? I understand that in left hand sides, slices might not be permitted.
But it should be allowed to provide a proper initial value at initialization.
Imagine a matrix whose first row and first column's elements are all at zero.
To provide multidim arrays while make them so awkward, make them hardly of any use. More freedom to provide (at least) static values to given slices / easily described submatrices. Like the exemple below, or like diagonal matrices ( I know there is (was ?) an AI over a new loop array aggregate, or something. I don't have to go that far).
It Was my rant of the week. I hate being stumbling stupidly on awkward syntax points, to discover I can probably not do what I would like.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: improvements for multidimensional arrays ?
  2018-05-17  0:32 improvements for multidimensional arrays ? Mehdi Saada
@ 2018-05-17  8:06 ` Stefan.Lucks
  2018-05-17 11:32   ` Mehdi Saada
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan.Lucks @ 2018-05-17  8:06 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

On Wed, 16 May 2018, Mehdi Saada wrote:

> Is it likely or not that we see some improvements over multidimensional arrays ?

Why?

> But it should be allowed to provide a proper initial value at initialization.
> Imagine a matrix whose first row and first column's elements are all at zero.

What is wrong with the code below?

    type Matrix is array (Natural range <>, Natural range <>) of Natural;

    M1: Matrix(1 .. 10, 1 .. 5) :=
      (1      => (others => 0),        -- first row 0
       others => (1 => 0, others => 1) -- first column in other rows 0,
 	                              -- all other entries 1
      );

    M2: Matrix(1 .. 10, 1 .. 5) :=
      (1 =>      (others => 0),         -- first row 0
       others => (1 => 0, others => <>) -- first column in other rows 0,
 	                               -- all other entries left undefined
      );

--------  I  love  the  taste  of  Cryptanalysis  in  the morning!  --------
www.uni-weimar.de/de/medien/professuren/mediensicherheit/people/stefan-lucks
----Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany----

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: improvements for multidimensional arrays ?
  2018-05-17  8:06 ` Stefan.Lucks
@ 2018-05-17 11:32   ` Mehdi Saada
  2018-05-17 16:38     ` Jeffrey R. Carter
  0 siblings, 1 reply; 5+ messages in thread
From: Mehdi Saada @ 2018-05-17 11:32 UTC (permalink / raw)


> What is wrong with the code below?
Nothing, I was wrong and used multidim arrays the wrong way. At least I could let out some steam... Unfortunate consequence of spending hours on formal logic and math !

That said, I couldn't find anywhere if a multidim array can do something an array of array simply can not. Is it only some kind of syntax sugar then ?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: improvements for multidimensional arrays ?
  2018-05-17 11:32   ` Mehdi Saada
@ 2018-05-17 16:38     ` Jeffrey R. Carter
  2018-05-17 17:21       ` Mehdi Saada
  0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R. Carter @ 2018-05-17 16:38 UTC (permalink / raw)


On 05/17/2018 01:32 PM, Mehdi Saada wrote:
> 
> That said, I couldn't find anywhere if a multidim array can do something an array of array simply can not. Is it only some kind of syntax sugar then ?

A multidimensional array type can be unconstrained in all dimensions. An array 
of arrays can only be unconstrained in the 1st dimension.

type C2D is array (Positive range <>, Positive range <>) of Character;

subtype S10 is String (1 .. 10);
type SL is array (Positive range <>) of S10;

With an array of arrays, the components are arrays and may be used as such.

V : SL (1 .. 10);
...
Ada.Text_IO.Put_Line (Item => V (5) );

-- 
Jeff Carter
"He didn't get that nose from playing ping-pong."
Never Give a Sucker an Even Break
110

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: improvements for multidimensional arrays ?
  2018-05-17 16:38     ` Jeffrey R. Carter
@ 2018-05-17 17:21       ` Mehdi Saada
  0 siblings, 0 replies; 5+ messages in thread
From: Mehdi Saada @ 2018-05-17 17:21 UTC (permalink / raw)


Now I get it, plain and simple. Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-17 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-17  0:32 improvements for multidimensional arrays ? Mehdi Saada
2018-05-17  8:06 ` Stefan.Lucks
2018-05-17 11:32   ` Mehdi Saada
2018-05-17 16:38     ` Jeffrey R. Carter
2018-05-17 17:21       ` Mehdi Saada

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