4 ms·
Huh I've never seen this approach. Very interesting solution, could be adapted to the JavaScript matrix libraries I bet.
by MH15 3y ago
Huh I've never seen this approach. Very interesting solution, could be adapted to the JavaScript matrix libraries I bet.
- thechao 3y agoThis is how TeX handles math — the "$" operator is an "inline" version of the same.
- estebank 3y agoIn Rust you could use a proc macro that parsed the block and translates the token to a new token stream that uses method calls with the appropriate operator precedence, for arbitrary operations you could want to define. You're effectively writing a compiler plugin and language extension at that point. For targeted niche domains, this might be worthwhile.
- bakkoting 3y agoThere's a not-very-active proposal to add operator overloading to JS which takes a similar scoped approach: https://github.com/tc39/proposal-operator-overloading https://github.com/tc39/proposal-operator-overloading