in reply to Precedence design question...'x' & arith
While I agree with your arguments that the current Perl 5 operator precedence could be improved, I don't feel it is appropriate to change operator precedence in a language as mature as Perl 5, with millions of lines of code in production use. That is, the (small) gain of your proposed change is not worth the considerable pain.
A new language, like Perl 6, is another matter. And I see that the Perl 6 folks agree with you; that is, Perl 6 is already using your proposed operator precedence for its Replication (x and xx) and Concatenation ~ operators.
By the way, notice that the current Perl 5 string multiply precedence is the same as Ruby and Python because they both use * as the string multiply operator. Ditto for string concatenation because Ruby and Python both use the + operator for that.
Though string multiply may be rarely used in general Perl coding, it is heavily used in golf ... so your proposed precedence change would certainly be welcomed by golfers. :) To illustrate, in The golf course looks great, my swing feels good, I like my chances (Part VI), a very rare example of Python out-golfing Perl and Ruby was given:
Python was shortest here because the string multiply operator is commutative in Python (only), allowing the parentheses to be removed. That said, the most common use of string multiply in golf is with a boolean expression, for example:$"x(318%$_/9) Perl " "*(318%i/9) Ruby 318%i/9*" " Python
and your proposed precedence change wouldn't help there."Zaphod Beeblebrox"x($n!=42)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Precedence design question...'x' & arith
by perl-diddler (Chaplain) on Jul 08, 2013 at 17:37 UTC |