News for hackers. Stuff that matters.
Re:Announcing The Zig Software Foundation by pirocks on Saturday July 11, 2020 @10:10PM (#23808103)
Because you need to specify the types of the operator in the symbol name as well.
Re:Announcing The Zig Software Foundation by tapirl on Saturday July 11, 2020 @10:21PM (#23808177)
But isn't the name is still needed if you define a function instead of overloading the operator?
Re:Announcing The Zig Software Foundation by thayne on Sunday July 12, 2020 @02:41AM (#23809373)
that just means you need a mangled name in the symbol table. I don't really consider that part of the "binary interface". The big problem with this in, for example, c++, is that the name is mangled in an implementation defined way. If the way the operator name is mangled is well specified, there's no reason it couldn't be used as a C function from another language.
Re:Announcing The Zig Software Foundation by matheusmoreira on Sunday July 12, 2020 @08:20PM (#23815882)
> that just means you need a mangled name in the symbol table

That alone is already enough to stop most if not all foreign language interfaces from resolving a symbol to a function pointer. That's the simplest hurdle to overcome. There are also complex mechanisms to deal with such as virtual method tables that figure into the calling conventions of overridable methods. Not even C++ compilers manage to keep the ABI stable between every compiler version: sometimes libraries compiled with a new version cannot be used with software compiled by an old version. Rust doesn't even have an ABI specification yet.

Re:Announcing The Zig Software Foundation by thayne on Monday July 13, 2020 @01:40AM (#23817503)
virtual method tables and operator overloading are orthogonal problems. Sure in many languages operator overloading is done using virtual methods, but it doesn't have to be. Operator overloading can dispatch based on static types rather than dynamic types.

That said, I do wish that there was a standardized way to expose vtables across foreign language boundaries. Although, I understand that differences in how vtables work across different languages, or even different implementations of the same language (cough cough c++ cough cough) would make creating a useful standard difficult.