Hacker News new | ask | show | jobs
by fluffybucktsnek 3 days ago
I don't see how it is unrelated. If have a custom type `A` with an overload on `+`, it will only affect places I used custom type `A`. If there wasn't operator overloading, I would just have to use a different notation to call the same function, but with possibly worse ergonomics (which is also why I think your solution doesn't really satisfy that, it doesn't read like algebra which is kind of the point). Given that type A is presumed to be custom, I don't see how place Y would be unrelated since it deliberately uses type `A`.

If we include operator overloading for any types, then sure. i32 + i32 might suddenly start meaning something else. But I think that's beyond the scope of what is normally asked by operator overloading.

1 comments

one is implementable entirely in the parser. overloading (operator or otherwise) in general is a deeper compiler feature