3 ms·
> > in OK?, 5 + 2 * 3 evaluates to 21, not 11, because addition and multiplication have equal operator precedence. >To be honest, I think this is actually smart
by jll29 4y ago
> > in OK?, 5 + 2 * 3 evaluates to 21, not 11, because addition and multiplication have equal operator precedence.
>To be honest, I think this is actually smart!
A better way to implement this is to always enforce parentheses around binary operators - which avoids misleading someone who is used to mathematical precedence (whether it is from maths or from using other languages).
- still_grokking 4y agoNot everybody likes LISP's syntax though. ;-) I actually think what Pyret does is reasonable.