binary selectors ambiguity and space
Stephan Rudlof
sr at evolgo.de
Mon May 15 22:58:33 UTC 2006
On 16.05.2006 00:10, nicolas cellier wrote:
>...
>> So your example
>>
>>>>> On 13.05.2006 02:10, nicolas cellier wrote: nc>... nc> Funny, in
>>>>> current 3.9 spaces are ignored: nc> i have '1 +- 2' interpreted
>>>>> as (1) + (-2)
>>>>> ...
>> is totally legal,
>
> No, it should be interpreted (1) +- (2).
> You must force a space between binary selector + and negated number - 2
> But (1 + - 2) should be interpreted (1)+(-2)
Correct.
As longer I think about it, I'm more curious about allowing the space
between the negating - and the number...
One example: how to parse
1 - 1
? From my interpretation of the standard (with the additional condition
of parsing from left to right) it should be parsed as
(1) (-) (1)
: Puuh, this is exactly what happens :-) ;
but in the case (1 + - 2) above the space before the 2 will be ignored
(not leading to a parse error), so the negation - binds from right to
left. So far so good. But this rule does *not* apply for the case of the
second + in (1 + + 2)...
Conclusion: the - is indeed very special.
Stephan
>...
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|