Hello,
First of all I know that perl syntax has limitations and I understand why
the reasons of the new syntax proposals. And I think the syntax proposals
are pretty good if you accept the syntax limitations. I don't think any of
them do consider that if somebody will write a PDL program he will use pdl
constructs and functions 99% of the time. So it should be user friendly and
this requires some radical changes in perl. But it looks like I am the only
one supporting this idea.

>The trouble is that that already has a meaning (although perhaps not a 
>particularly useful one).

Hmm. I thought perl6 would be a rewrite of the language. I know that it is
not intended to change the whole language radically, but .... Since the
former syntax was designed without matrices in consideration, it is not
well suited for perl6. I am sure if Larry Wall designed perl5 with matrices
in mind, he would have designed the syntax differently. So I don't really
see any point of forcing the old syntax; it will break sooner or later (if
not in the sense of syntax limitations than in the artistic sense).

>Besides, the "confusing" syntax you describe is analogous to:
> 
>   [$i,$j,$k]  creating an anon array ref, where the variables are 
>values
>and
>   @a[$i,$j,$k] being an array slice, where the variables are indices.

First of all, my guess is that if somebody is writing pdl code he won't get
confused with anon array refs since he is not using them most of the time.
It is confusing if the same thing resembles two different things in pdl
syntax.
@a[$i,$j,$k]
No, this isn't confusing because there is "@a" infront of it, but
@a[[$i,$j,$k],[$x,$y,$z]] is confusing since [$x,$y,$z] doesn't have a "@"
in front of it. And more than that my brain can't quickly manage so many
nested structures. But this is just my feeling.
Don't get me wrong, I like puzzles and I like stimulating my brain but I am
talking from the point of view of language design.

Compare
>@p = [[1,2,3],
>      [4,5,6],
>      [4,5,6],
>      [6,3,3],
>      [2,3,5],
>      [3,5,5],
>      [3,5,5],
>      [2,2,2]];

with 
@p = [1 2 3;
          4 5 6;
          4 5 6;
          6 3 3;
          2 3 5;
          3 5 5;
          3 5 5;
          2 2 2];

Matlab actually goes one step more and thinks "\n" is equivalent of ";"
inside matrix definition and in this case you don't even have to type ";"'s
if you are using multiple line syntax.
Is it only me? Isn't it very annoying to type 40 extra characters? maybe
more perl friendly syntax might be:

@p = qw_extended(
         [1 2 3;
          4 5 6;
          4 5 6;
          6 3 3;
          2 3 5;
          3 5 5;
          3 5 5;
          2 2 2]
);

if qw() will support this.

>I see things differently...  I can easily visualize 3-d, and although I 
>can't do higher, I see no reason to treat -any- particular D 
>representation special.  

Everybody can visualize 3-d, but I think visualizing 3-d is not very
relevant here. Your text editor is 2-d, so you are pretty much limited to
2-d.

>I just don't know implement that ideal -- 
>computers are linear, after all.

The difference between perl and other computer languages is that perl is
designed to work similar to how we think, not similar to the way how
computers will work. Moreover if you look at other leading software
packages I think they pretty much aggree with me.

>Two comments on your syntax:
>
>scalers are singular, and are represented by $
>arrays  are plural,   and are represented by @

I was using the old syntax since I thought there wasn't any consensus on
the new syntax.
Thanks,
Baris.

*********** REPLY SEPARATOR  ***********

On 8/31/00 at 12:17 AM Buddha Buck wrote:

>> > @a[[$i,$j,$k], [$x,$y,$z]]
>> 
>> I think it is more readable if you have different type of parantheses:
>> @a[($i,$j,$k), ($x,$y,$z)]
>
>The trouble is that that already has a meaning (although perhaps not a 
>particularly useful one).
>
>The list ($i,$j,$k) in scalar context evaluates to its final element, 
>$k, so @a[($i,$j,$k),($x,$y,$z)] becomes equivilant to @a[$k,$z], which 
>is a two-element slice of the array @a....  Not -quite- what we wanted.
>
>What ever syntax we use is going to have to be compatable with the 
>syntax used by the rest of the language.  It does no good to choose to 
>use a syntax for matrix operations that already has a well-defined (if 
>pointless) interpretation.  The two proposals for matrix indexing (mine 
>and Jeremy Howard's) extend Perl's syntax in different, but 
>perl-friendly ways.
>
>Jeremy's @a[[$i,$j,$k],[$x,$y,$z]] syntax  would, in Perl 5 terms, be a 
>semantic error.  [$i,$j,$k] is easily parsed into an anonymous array 
>ref, so we are trying to index @a by (two) array refs, which doesn't 
>have a meaning in Perl 5.  Using that to mean multi-dimensional array 
>access is a reasonable extension.  It also means you can do things like 
>@a[$point[0],$point[1]] where @point is a list of lists.
>  
>> Also:
>> [[$i,$j,$k], [$x,$y,$z]]
>> kind of resembles to creating a piddle where all these variables are the
>> values, whereas in your example of accessing two elements
>> @a[[$i,$j,$k], [$x,$y,$z]]
>> the variables are actually indices, not the values. Two similar
syntaxes,
>> two different meanings open to possible mistakes and confusion.
>
>The syntax [[$i,$j,$k],[$x,$y,$z]] already has in perl the meaning of 
>"an anonymous array containing two anonymous arrays of three elements 
>each".
>
>I've not noticed any proposals for multi-dimensional array literals 
>yet.  I don't have any good idea how to do it.
>
>Besides, the "confusing" syntax you describe is analogous to:
> 
>   [$i,$j,$k]  creating an anon array ref, where the variables are 
>values
>and
>   @a[$i,$j,$k] being an array slice, where the variables are indices.
>
>the two syntaxes are as similar to what you described, with as 
>different meanings, and yet perl has been living and dealing with both 
>those forms for 4-5 years now without too much confusion.
>
>> 
>> More on syntax for creating pdls:
>> Can we just get rid of unnecessary commas. Spaces should be good enough:
>> $p = pdl [[1 2 3][4 5 6]];
>> 
>> Also aren't there too  many and confusing "[" and"]"s in the syntax.
This
>> makes difficult and unreadable to create matrices by hand? For an 3x8
>> matrix (without commas):
>> $p = pdl [[1 2 3][4 5 6][4 5 6][6 3 3][2 3 5][3 5 5][3 5 5][2 2 2]];
>> Do you really feel that this looks like a 2-d matrix. It feels like a
3-d
>> matrix to me when I first see it. This is very ugly syntax and doesn't
fit
>> human perception. Even though we can't visualize 10-d spaces, we are
pretty
>> good at visualizing 2-d objects. So this kind of complicated syntax can
be
>> suitable for n-d representation but the first two dimensions should be
more
>> natural.
>> Easier syntax would be:
>> $p = pdl [1 2 3, 4 5 6, 4 5 6, 6 3 3, 2 3 5, 3 5 5, 3 5 5, 2 2 2];
>> or
>> $p = pdl [1 2 3; 4 5 6; 4 5 6; 6 3 3; 2 3 5; 3 5 5; 3 5 5; 2 2 2];
>
>I don't see either of these as better for human perception than
>
>@p = [[1,2,3],
>      [4,5,6],
>      [4,5,6],
>      [6,3,3],
>      [2,3,5],
>      [3,5,5],
>      [3,5,5],
>      [2,2,2]];
>
>The difference is that I chose to write the 2-D structure in a 
>human-visible 2-d form.  I could have written it without commas the 
>same way.  It also makes it easy to go to n-d forms without a problem:
>
>@cube = [ [[1 2]
>           [2 3]],
>          [[3 4]
>           [4 5]],
>          [[5 6]
>           [6 7]]  ];
>
>> 
>> Now if you are wondering how this would scale to multiple dimensions
since
>> this is specific to 2-d, here is a 3x8x2 matrix:
>> $p = pdl [1 2 3; 4 5 6; 4 5 6; 6 3 3; 2 3 5; 3 5 5; 3 5 5; 2 2 2][1 2 3;
4
>> 5 6; 4 5 6; 6 3 3; 2 3 5; 3 5 5; 3 5 5; 2 2 2];
>> or better written:
>> $p = pdl [1 2 3; 4 5 6; 4 5 6; 6 3 3; 2 3 5; 3 5 5; 3 5 5; 2 2 2]
>           [1 2 3; 4 5 6; 4 5 6; 6 3 3; 2 3 5; 3 5 5; 3 5 5; 2 2 2];
>> 
>> Is this a limited or confusing syntax? No. Here instead of assuming that
>> vectors are the smallest building blocks, I assumed 2-d matrices are the
>> building blocks and vectors are just 2-d matrices with the second
dimention
>> equal to zero. Well here is how current synta will handle a column
vector
>> anyway:
>> $p = pdl [[3], [4], [2], [3], [4], [2], [3], [4], [2]];
>> and my suggested syntax:
>> $p = pdl [3 ; 4 ; 2 ; 3 ; 4 ; 2 ; 3 ; 4; 2];
>> 
>> As I mentioned we can visualize 2-d easily so there is nothing wrong to
use
>> a special syntax for the first two dimensions. Isn't this very perlish?
>
>I see things differently...  I can easily visualize 3-d, and although I 
>can't do higher, I see no reason to treat -any- particular D 
>representation special.  I just don't know implement that ideal -- 
>computers are linear, after all.
>
>Two comments on your syntax:
>
>scalers are singular, and are represented by $
>arrays  are plural,   and are represented by @
>
>Get these confused, and more experienced heads than I will complain 
>about it.
>
>The fact that PDL uses $p to represent an "array" is an artifact caused 
>by Perl 5's lack of true multidimensional arrays of sufficient 
>efficiency to write PDL with standard data types.  When a non-PDL-using 
>Perl old-hand sees $pdl, they might think "a scalar", or "an instance 
>of class PDL", or even "a reference to a hash blessed as class PDL", 
>but they won't think "array".
>
>There is no reason in Perl 6 to be forced to make that compromise -- 
>yet.
>
>> Also as I mentioned before %90 or maybe more of the time pdl will be
used
>> for 1-d or 2-d calculations.
>> 
>> Baris.
>> 
>
>-- 
>     Buddha Buck                             [EMAIL PROTECTED]
>"Just as the strength of the Internet is chaos, so the strength of our
>liberty depends upon the chaos and cacophony of the unfettered speech
>the First Amendment protects."  -- A.L.A. v. U.S. Dept. of Justice



Reply via email to