Buddha Buck wrote:
> 
> $matrix[$x,$y,$z] already has a reasonable meaning.  If we
> appropriate that syntax, how do you take slices of a matrix?

My point too, only someone else pointed out that this is actually
@matrix[$x,$y,$z].

STILL, the fact that I've been hacking Perl since 4 and missed this
worries me that many others will confuse the two also.

> I'm thinking I like using ; as an index separator, as in
> $matrix[$x;$y;$z].  This -shouldn't- be a massive problem for parsing;
> we are already using ; in "for(;;)" as something other than a statement
> separator.

Great minds think alike! Are you sure you didn't read my email? ;-)

http://www.mail-archive.com/perl6-language-data%40perl.org/msg00035.html

> This would also allow us to do slices like: @matrix[1,3,5;2,4,6;3] to
> get a 3x3x1 resulting matrix consisting of $matrix[1;2;3],$matrix[1;4;3]
> , etc.

Now THAT seems pretty damn cool. REALLY cool. I'll have to think some
more, but my initial reaction is YES!

Buddha, RFC this! The stuff you put below here is great. It's easily the
most flexible format proposal I've seen.

> How are literal multidimensional arrays written?  For this, I'm not
> sure...  My first thought was to separate the rows with ;, as in
> @matrix = ( 1,2;3,4).  But that doesn't scale well to more than 2d.
> Then I thought just using the standard list of list syntax:  @matrix =
> ( [1,2],[3,4] ).  But is that a list of array references, or a 2-d
> array?  Next, I thought of combining the two:
> 
> @matrix3x3x3 = ( [[ 1, 2, 3];
>                   [ 4, 5, 6];
>                   [ 7, 8, 9]];   # row 0;
>                  [[10,11,12];
>                   [13,14,15];
>                   [16,17,18]];   # row 1;
>                  [[19,20,21];
>                   [22,23,24];
>                   [25,26,27]] ); # row 2;
> 
> I think parenthesis might be better, using [] for reference
> constructors, but any way you look at it.
> 
> Should explicit bounds and declarations take place before use?  Is "my
> @matrix:bounds(3,3,3);" necessary?  I don't know about you, but
> autovivication of array elements and boundlessness is a feature I like
> about perl.  Why should "$array[1000] = $x" work without predeclaration
> but "$matrix[1000;1000;1000] = $x" shouldn't?
> 
> Just my thoughts?

Reply via email to