News for hackers. Stuff that matters.
Re:Many programming languages have infix expressions, but ge... by biotech on Monday February 01, 2010 @12:22AM (#1091850)
The fundamental misunderstanding here is how we relate our parsing of mathematical expressions to the way a compiler parses expressions:

While we can parse the following expression properly:

    a < b < c
parses to:

    (a < b) AND (b < c)
obviously most compilers don't do that. As others have pointed out, the < operator should not be associative.

The misunderstanding, though, is that the original expression

    a < b < c
actually could be parsed (I'm making a bunch of assumptions about the grammar and parser type here) by treating ..<..<.. as a ternary operator, like ?: in C++.

Then, in the syntax tree, the compiler could re-organize the expression to be the correct an unambiguous:

    (a < b) AND (b < c)

There are no comments on this comment yet.