From: mathew
Date: 2006-03-17T05:55:16+09:00
Subject: Re: [ ruby-Bugs-3843 ] "not" operator used in expression that is a method parameter can generate syntax error
Brian Mitchell wrote:
> On 3/16/06, mathew wrote:
>
>> I still don't understand why foo(!(1<2)) is OK, but foo(not(1<2)) isn't.
>>
>> The pickaxe says that the only difference between '!' and 'not' is
>> precedence, and in these two cases everything is explicitly bracketed so
>> precedence shouldn't be involved.
>>
>> What am I missing?
>>
>
> foo(not(1<2), 3)
> or more clearly bound if I understand Matz correctly:
> foo(not((1<2),3))
>
Except comma isn't an operator according to the Pickaxe. Could be a
documentation error, I suppose.
Accepting for a moment that comma is an operator...
I don't see how it makes sense to give an error for foo(not(1<2)) just
because a completely different statement foo(not(1<2),3) would have a
precedence clash. I mean, method {|x| 2*x } is allowed, even though
method {|x| 2*x }, {|y| 3*y} wouldn't be.
What if boolean keywords weren't lower precedence than comma?
I've never encountered a language where f(x) was OK but f(not(x))
wasn't, so this is Surprising (TM). I mean, it works in Perl, for example.
mathew
[ Not that I'm holding up Perl as a role model, of course. ]