Re: Array initialization

David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Mon, 27 Jan 2003 10:58:07 -0500
Newsgroups gmane.comp.lang.moto.devel
Message-ID <[email protected]>
On Monday, January 27, 2003, at 11:31  AM, Stefano Corsi wrote:

> I'm working on array initialization and I've managed to get to this 
> point (at
> least in interpreter mode...).
> Array[] pippo = [
>       [1,2],
>       [2,4],
>       [
>          [8,9],
>          [10,11]
>       ]
>    ];
>
Very cool! I'm surprised though that saying 'Array[] pippo' works ... 
That sounds like a bug on my part. I didn't realize I still had the 
built in 'Array' type. I don't think I need it anymore since the 
'Arrayness' of a MotoVar / MotoVal is really determined by the 'dim' 
attribute. That type should probably go away.

> print (<int[]>(<Array[]>pippo[2])[1])[1];
>
> At the moment I've used square brackets for being confortable with the
> grammar. Of course it could be possible to use curlies, with some more
> effort...
>
> Isn't the print statement too awkward? Do you think an implicit cast 
> so that
> you can do:

If pippo is declared as 'int[][][] pippo' you should be able to do the 
following print fine without the cast.
>
> print pippo[2][1][1];
>
> could be easily done?
>
> With simple one-dimensional array it work fine without casts (not even 
> at
> initialization time. I get the tipe from the first value in the 
> list...).
>
> Stefano
>

-Dave