Hacker News new | past | comments | ask | show | jobs | submit login

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)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: