in reply to Perl 6 - Operator renaming

What I'd really like to see change, is not the shape of the operators ( . becomes ~, -> becomes . or nothing, & becomes +& or ~&, sub { becomes {,... ). It's the precedence of operators.

I understand that in perl6, comma had to have a higher precedence than assignment, for C compatibility. But is this the case with perl6 too? In perl6, the comma will not have its perl5 meaning in scalar context anymore, so couldn't we also raise the precedence of the comma, so that we can write @numbers = 12, 5, 4, 8, 9, 11; instead of @numbers = (12, 5, 4, 8, 9, 11);? Also, will concatenation finally have lower precedence than addition and subtraction? It's a bit annoying in perl5 that their precedence is equal, so you have to parenthisize print "2 + 5 = " . (2 + 5);.

Update 2006 Jun 12: Funnily, list assignment now has a low enough precedence in perl6 for this to work.

Replies are listed 'Best First'.
Re^2: Perl 6 - Operator renaming
by TimToady (Parson) on Sep 08, 2005 at 15:07 UTC
    The design team certainly considered (at length) changing the precedence of comma with respect to assignment, but in the end, after weighing all the pros and cons, it seemed to us that cultural continuity and enforced visual encapsulation won out over the slight gain in convenience.

    As for the relationship of concatenation and addition, when we had a choice between adding more precedence levels or unifying precedence levels, we had a slight bias towards unification, so anything remotely resembling addition or multiplication tended to end up at those precedence levels. This is one of those areas where you have to balance out the need for extra parens with the need to keep a complex precedence table in one's head, and in this case we (again) opted for the extra parens in order to keep the mental model simpler. It doesn't hurt the reader of your code to have to parenthesize a few things, and while Laziness is one of the chief virtues of a programmer, with Perl 6 we're trying to take into account the Laziness of the reader as well as the writer.

      with Perl 6 we're trying to take into account the Laziness of the reader as well as the writer

      Now I feel enthralled. (++)

      Cheers, Sören