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

Unary and binary - can be given different precedence, because there is never ambiguity as to whether you're in front of a unary minus or a binary minus. A binary operator is never encountered at the beginning, or after a parenthesis, or after another binary operator, therefore those are the cases where you'd have a unary - or +.

Rather, the problem is whether -2 is parsed as a numeric literal, or a unary minus followed by a numeric literal (which would only include positive numbers).






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

Search: