Mark Lentczner wrote:

Awhile back, I saw Larry Wall give a short talk about the current design of Perl 6. At some point he put up a list of all the operators - well over a hundred of them! I had a sudden inspiration, but it took a few months to get around to drawing it...

http://www.ozonehouse.com/mark/blog/code/PeriodicTable.html

Fascinating. I wish I had a printer big enough to do it justice.

Some thoughts:

Anonymizers: Is (...) really an anonymous-value constructor, in the same class as [...] and {...}? Assuming that C-like comma isn't around any more (was that finalized?) parentheses aren't really doing anything fancy with respect to list construction. Now they are perhaps merely grouping operators at precedence level 0.

Declars: does "sub" fall into this category? I ask because of the symmetry of
$x = sub { ... };
and
$x = hash { ... };
but perhaps sub belongs in a different spot.


Comparisons and junction/bitmasks: The table has comparisons binding tighter than junctions and bitwise operations. This is how Perl 5 has it, which is because Perl 4 had it that way, which ultimately is because C had it that way. One of the creators of C is on record[*] as saying how that was an unfortunate mistake, because it meant you had to put parentheses around
if ( (x & 0xF) == 0xF )
or you didn't get the expected behaviour.


Since we're effectively abandoning a C-like pantheon of operators in Perl6, maybe this is the time to make it right, and put the precedence as:
multiplication (6)
addition (7)
shifts (8)
bitmasks (9)
comparison (10, 11)
logical operators (12)


It would then mean no parentheses were needed in this Perl6:
if $x == 5|6 { ... }
(though I could buy an argument that putting parentheses in would be a Good Idea).


[*] http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

Reply via email to