On Thu, 26 Sep 2002, Sean O'Rourke wrote:
: Thanks for taking the time to write this out.
: 
: On Thu, 26 Sep 2002, John Williams wrote:
: > perl6 operator precedence
: >
: >            left        terms and list operators (leftward) [] {} () quotes
: >            left        . and unary .
: >            nonassoc    ++ --
: >            left        is but
: 
: This would lead to some scary things, I think:
: 
:       $a = 3 + 4 but false
:       => (= $a (+ 3 (but 4 false)))
: 
: Of course, so does having low precedence:
: 
:       $a = 3 but false + 4
:       => (= $a (but 3 (+ false 4)))
: 
: but I think the latter is unnatural enough that it deserves parens, so I'd
: put 'but' above comma (and probably '='), but below just about everything
: else.

Could perhaps unify with C<..>.  Wouldn't hurt for it to be non-associative like C<..>.

: > Larry mentions that other precedence unifications are possible.  I can see
: > the following as possibilites.  Are there others?
: >     & with &&
: >     | with ||
: 
: It seems like a good idea to me to encourage people to think of bitwise
: ops as mathematical, not logical, so I'd rather see them with different
: precedences.  Plus, anything that significantly goes against people's
: hard-wired C expectations will just lead to confusion and pain.  Finally,
: having '|' below '&&' will probably lead to strange things, e.g.
: 
:       1|2 && 3|4
:       => 1 | (2 && 3) | 4

I'd be more inclined to unify & and | with * and +, since that's
exactly what they are in Boolean algebra, where 1*1 == 1.  I think
the argument that it breaks C compatibily is weak in this case,
since almost everyone admits that C is broken in this respect.

Alternately, we take | and & away from bitwise ops and do something
more useful with them.  I have been asked privately by a sight
impaired person to consider using | as the separator for parallel
streams rather than the almost invisible ; character, for instance.
Being a bit sight impaired myself at the moment, I have great empathy...

Larry

Reply via email to