[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Unary Minus for Constants
- From: Ralph Hempel <rhempel@...>
- Date: Thu, 09 Aug 2007 09:16:38 -0400
Roberto Ierusalimschy wrote:
However, the Lua parser takes the preceding "-" and does not
pass it to the numeric conversion routine.
Instead, it passes everything AFTER the "-" and then does the
unary minus as defined for the default arithmetic type.
Most languages do this. If you include the "-" as part of the number
you will need some trick to parse "x-1", as it would read as a variable
("x") followed by a constant ("-1"), with no operation.
I understand the reason behind the requirement, I just did not
appreciate the side effects until I ran into the problem :-)
The language and the Lua interpreter is operating exactly as it
was designed and intended to in this case, it's my workaround
that is at fault.
All this shows is that no matter how carefully one may consider
a patch or change to a system, only extensive testing will prove
that it works and more importantly that nothing else got broken.