Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Huh I've never seen this approach. Very interesting solution, could be adapted to the JavaScript matrix libraries I bet.


In 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.


This is how TeX handles math — the "$" operator is an "inline" version of the same.


There'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




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

Search: