I've recently been reminded how much I hate the fact that C got the precedence for the bit-wise operators completely wrong (something which I believe at least one of Kernighan and Ritchie have publicly admitted to).

I know I'm way past the Perl 6 RFC process and this isn't the Perl 6 discussion list. But I wanted to throw this out here first...

Wouldn't it be great if Perl 6 were to fix this brain damage that has plagued (well, a somewhat minor plague) C, C++, Perl 4, and now Perl 5?

Here is how I'd prefer to have operator precedence table in Perl (note that I'm listing only Perl 5 operators even though I know these change will never make it into Perl 5):

AssociativityOldNew
left terms, (leftward) list ops terms, (leftward) list ops
left -> ->
nonassoc ++ -- ++ --
right ** **
right ! ~ \ unary + and -~ \ unary + and -
left =~ !~ =~ !~
left * / % x * / % x
left + - . + - .
left << >> << >>
left (n/a) &
left (n/a) | ^
nonassoc named unary ops named unary ops
nonassoc < > <= >= lt gt le ge < > <= >= lt gt le ge
nonassoc == != <=> eq ne cmp == != <=> eq ne cmp
left & (n/a)
left | ^ (n/a)
right (n/a) !
left && &&
left || ||
nonassoc .. ... .. ...
right ?: ?:
right = += -= *= etc. = += -= *= etc.
left , => , =>
nonassoc (rightward) list ops (rightward) list ops
right not not
left and and
left or xor or xor

This preserves the relationship between the operators that you might already be mixing together, but removes the major breakedness of, for example, == binding tighter than &, |, and ^ so that you could finally just say: if(   0 == $mask & $value  ) {

        - tye (but my friends call me "Tye")

In reply to Will/Can Perl 6 clean up the bit-wise operator precedence mess? by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.