In message "[ruby-talk:01177] Re: Possible bug in ruby-man-1.4"
on 00/01/24, Dave Thomas <Dave / thomases.com> writes:
|> % perl -le 'print -2**2'
|> -4
|> % python -c 'print -2**2'
|> -4
|> % ruby -e 'p -2**2'
|> -4
|> % ruby.new -e 'p -2**2'
|> 4
|
|Now there's a problem ;-(
|
|Maybe the answer is to get rid of the concept of negative numeric
|literals, so there's never any ambiguity as to whether -2 is a literal
|of a method call? Then, as an optimization, the parser could notice
|<Fixnum>.-@ terminal pairs and replace them with a negated
|Fixnum.
That is the current behavior (without optimization).
The problem is about the contradiction below.
current modified
-13.remainder(4) => better be (-13).remainder(4) yes no
-2**2 => better be -(2**2) no yes
There may be good syntax rules to solve this.
matz.