I'm trying to write a revised operator precedence table for perl6,
similar to the one in perlop.pod.

This is what I have come up with based on Apocalypse 3 and Exegesis 3.  
Does anyone have comments?  I'm not sure if the precedence 
for : (adverb) or 'is' and 'but' are quite right.


perl6 operator precedence

           left        terms and list operators (leftward) [] {} () quotes
           left        . and unary .
           nonassoc    ++ --
           left        is but
           right       **
           right       ! \ and unary ~ + - * _   
           left        =~ !~
           left        * / % x
           left        + - _
           left        << >>
           right       named unary operators, -X
           left        < > <= >= lt gt le ge == != <=> eq ne cmp
           left        &
           left        | ~
           left        &&
           left        || ~~ //
           nonassoc    ..  ...
           right       ??::
           right       = := **= += -= _= *= /= %= x= &= |= ~= 
                            <<= >>= &&= ||= ~~= //= 
           left        , =>
           left        ;
           left        :
           nonassoc    list operators (rightward)
           right       not
           left        and
           left        or xor err

Here is a list of changes from perl5:
        . becomes _
        -> becomes .
        == etc unified with < etc, and given left associativity
        binary ^ becomes ~
        ?: becomes ??::
        added ~~ // err
        added ; with lower precedence than ,
        added unary * and _ with same precedence as unary + -
        added binary :=
        added unary . with same precedence as binary . 
                ( .foo === $self.foo )  
        added : (adverb operator) with low precedence(?)
                print foo: $x, $y, $z;                  # lower than ,
                my $fh = open $filepath : mode=>'rw';   # lower than =>
        added 'is' and 'but' with high precedence(?)
                my $thing is constant = 3 but false;    # higher than =

Larry mentions that other precedence unifications are possible.  I can see 
the following as possibilites.  Are there others?
        & with &&
        | with ||
        << >> with * /


~ John Williams

Reply via email to