At 09:45 AM 04-26-2002 -0700, Larry Wall wrote:
>Tim Bunce writes:
>: For perl at least I thought Larry has said that you'll be able to
>: create new ops but only give them the same precedence as any one
>: of the existing ops.
>
>Close, but not quite.  What I think I said was that you can't specify
>a raw precedence--you can only specify a precedence relative to an
>existing operator.  That way it doesn't matter what the initial
>precedence assignments are.  We can always change them internally.
>
>: Why not use a 16 bit int and specify that languages should use
>: default precedence levels spread through the range but keeping the
>: bottom 8 bits all zero. That gives 255 levels between '3' and '4'.
>: Seems like enough to me!
>:
>: Floating point seems like over-egging the omelette.
>
>It's also under-egging the omelette, and not just because you
>eventually run out of bits.  I don't think either integer or floating
>point is the best solution, because in either case you have to remember
>separately how many levels of derivation from the standard precedence
>levels you are, so you know which bit to flip, or which increment to
>add or subtract from the floater.

<snip>

So you'd have something like:

sub operator:mult($a, $b) is looser('*') is inline {...}
sub operator:add($a, $b) is tighter("+") is inline {...}
sub operator:div($a,$b) is looser("/") is inline {...}

assuming default Perl5 precedences for *, *, and / you would have the 
precedence strings for *, +, /, mult, add, and div to be "S", "R", "S", 
"S2", "S1", "S2" respectively?  So mult and div would have the same 
precedences?

Hmmm....  What problems would be caused by:

sub operator:radd($a,$b) is tighter("+") is inline is rightassociative {...}
sub operator:ladd($a,$b) is tighter("+") is inline is leftassociative {...}

Right now, all the operator precedence levels in Perl5 have either right, 
left, or no associativity, but they do not mix right and left associative 
operators.  Will that be allowed in Perl6?


>Larry

Reply via email to