The real nightmare tends to show up when you duplicate a modifier. What does
.method given $x given $y; # which object's .method is called?
mean? It gets worse below....
I made a mistake in my original post, they definitely need to be left- associative. Your example should obviously be interpreted as:
(.method given $x) given $y; # calls $x.method
I think this is similar to how I mentioned that a duplicate 'for' is pointless. Just because pointless modifier combinations exist doesn't mean multiple modifiers in general are a problem.
lowest? why lowest?
Ehm, because that is consistent with current behavior?
Careful with that.... If you make it a lowest precedence operator,
$x = $y if $z; # = is higher precedence
Does it get assigned if $z is undefined?
since 'if' has a lower precedence than '=', this is: ($x = $y) if $z; or equivalently $z and ($x = $y)
In either case, the assignment is done if $z is true
I may be missing something, but
print if $x if $y; # ??
Are you saying "test $y, and if it's true, test $x, and if it's true then print"?
Yes
I suppose that might work....but that still makes it high priority, doesn't it?
It means the left side is not always evaluated; that's short-circuiting and has nothing to do with precedence. Notice how in perl 5 the 'or' operator is in the lowest precedence class, but certainly short-
circuits (think "foo or die")
print "$x,$y\n" for $x -> @x for $y -> @y; # is that approximate?
Syntax error. The -> operator doesn't make sense without a block. See http://www.perl.com/pub/a/2002/10/30/topic.html
Still,
print for @x for @y; # @y's topic masked
would probably make no sense unless ...
Note that I actually *said* it makes no sense. I have to admit that if the conditionals (if, unless, when) would be operators, I'd have trouble to think of a situation where multiple modifiers are useful at all; which I why I said making the conditionals infix-operators would probably suffice.
Then again, I just thought up (perl 5 style):
print for split while <>;
but I have to admit I can probably live without the ability to write something like that ;-)
-- Matthijs van Duin -- May the Forth be with you!