| ▲ | astrobe_ 3 hours ago | |
well I'll be that guy... If you're going to disturb the normal way of righting expressions, RPN or prefix notation (AKA Polish Notation) could be a better option. Both don't need parenthesis because they don't need precedence/priority rules - which are obviously a disadvantage of the infix notation. The HP 48 famously took the bet of going against the mainstream notation. I wonder to what extent this is one of those "accidents of history". RPN moreover simplifies parsing, as shown by the Forth language. Prefix notation, as used by for instance Lisp, doesn't actually need parenthesis either; Lisp uses them because it allows extensions over basic operators and more generally "variadic" operators and functions (e.g. (+ 1 2 3 4)). Without this "fancy" feature, prefix notation is unambiguous as well: / + 1 2 3. [1] On a side note, Smalltalk is one of the few languages that said "duck it", and require explicit parenthesis instead - which is IMO, not an insane approach when you see that for languages with 17 levels of priority like C, you end up putting parenthesis anyway as soon as the expression is not trivial "just to be sure" (e.g. because it mixes boolean operators, arithmetic operators and relational operators as in a & 0xF < b + 1). | ||
| ▲ | NetMageSCW 2 hours ago | parent [-] | |
The HP 48 followed a couple of decades of HP calculators using RPN (hardly famous, just an evolution). HP’s first calculator used RPN. I recommend https://www.hpmuseum.org/ for more details. | ||