Closed flying-sheep closed 10 years ago
The ambiguity stems from the somewhat leaky convention that whitespace isn't significant. In this case, whitespace is not significant until it is interposed between two characters which comprise a single symbol.
but identifiers are also single symbols separated by whitespace, and are like this in most programming languages that are considered without significant whitespace. so are keywords: else if
≠ elseif
The point is, novice R programmers might write something like
x=1;
y=2;
if(y<-x) print(1) else print(2) ## what? y isn't less than negative x, why do we print 1?
It's ambiguous in that there are two possible ways to parse y<-x
, but the parser chooses the '<-
is a symbol' case (rightly so). A novice R programmer who doesn't realize <-
is used for assignment and hates whitespace would run into surprises like this.
You’re right. Could be a bit clearer on the page, but now i got it :)
but that’s not ambiguous.
<-
is simply a symbol, so if it occurs together, it’s always the assignment operator. (afaik)