4 ms·
Good point. Smalltalk is a source of inspiration, though I am unaware of how it handles math expressions in particular. The solution as I see it: You’d have to
by redbar0n 5y ago
Good point. Smalltalk is a source of inspiration, though I am unaware of how it handles math expressions in particular.
The solution as I see it: You’d have to enforce using parentheses (in line with «explicit over implicit»), alternatively enforce an ordering of math expressions so that the operators with the highest precedence has to be placed first. This might even be beneficial in tail call optimization, since it minimizes what has to be kept in memory (for the compiler as well as the human reader).
- scroot 5y ago> I am unaware of how it handles math expressions in particular. It does not automatically do order of operations. You have to explicitly use parentheses, as you say. However methods in Smalltalk tend to be quite short do to the nature of the system so it tends to not be as messy as one might expect.
- lolinder 5y agoI don't think that enforcing an order of expressions would help at all with optimization, since it's just a syntactic requirement. You should end up with an equivalent abstract syntax tree, and as a result the same underlying machine code.