3 ms·
Don’t even need operator overloading for vectors/matrices. It would be fine if we could simply define new operators (functions with infix notation) and use thos
by chongli 3y ago
Don’t even need operator overloading for vectors/matrices. It would be fine if we could simply define new operators (functions with infix notation) and use those. This would allow us to define an operator for matrix multiplication, matrix-vector product, dot product, and cross product.
Having to define these operators as functions with unique text names is extremely ugly and serves no purpose that I can see.
- luckystarr 3y agoWhat was the language which used backticks to transform any function into an infix binary operator? Ruby? Perl? Something like this could actually fulfill Andrews goal of not having any hidden control flow, as the function would be plainly visible. The other thing of course would be, what then the valid function names would be? Definitely not `*` but probably `×` or whatever.
- chrisoverzero 3y ago> What was the language which used backticks to transform any function into an infix binary operator? Ruby? Perl? Haskell.
- tyg13 3y agoHaskell does this.
- rscho 3y agoRacket
- throwawaymaths 3y agoI think the change could be as limited as a change to the parser. You could also enforce hygenicity (limiting scope only to places where it is asked for) by requiring it to be const @"..." = @import("my_operator.zig").add; For example. Then in the code the parser transforms (a ... b) to @"..."(a, b)