Re:Announcing The Zig Software Foundation
by dnautics on Saturday July 11, 2020 @09:30PM
(#23807862)
Ok so (seriously), as an experiment, compile a c++ code file that overloads, say, "+" into a .so file (let's keep it to elf format then) and let us know what the "true" name of the corresponding function is by hexdumping the .so
[ Parent
| on HN ]
Re:Announcing The Zig Software Foundation
by asdfasgasdgasdg on Saturday July 11, 2020 @11:44PM
(#23808622)
Many non-extern C++ names are mangled in .so files, not just operators. I don't see how that affects the ABI (i.e. the calling conventions of the functions). It just means you need to use a library to demangle in order to call the correct function.
Yes, and it is a choice to not support any of them due to complexity. And as a result, you don't get operator overloading.
Zig supports C ABI, not C++ ABI.
Re:Announcing The Zig Software Foundation
by asdfasgasdgasdg on Sunday July 12, 2020 @08:21AM
(#23810804)
You are confused. Supporting the C ABI and operator overloading are orthogonal. One is about conventions for saving registers and such. The other is about the naming of functions. Zig probably has a principled reason to not support operator customization, but ABI concerns aren't it.
You were the one that brought up C++, so if I'm confused, it's because what you wrote.
Re:Announcing The Zig Software Foundation
by asdfasgasdgasdg on Sunday July 12, 2020 @09:39PM
(#23816352)
I did bring up C++, but I did not bring up operators. The question at hand is whether ABI concerns prevent operator overloading. Plainly, that is not an issue.
Just run the hexdump as it is through c++filt and be done. Yes, name mangling is an inconvenience and sometimes it is annoying, but it's not as bad as you make it sound.
and so now you have to add another tool to your toolchain, and if you want to become self-hosting, you have eventually refactor the whole thing, etc... And Zig doesn't generally have plans to support the same types that are available in C++ so realistically the only thing you get is operator and basic function overloading.
And in the C++ community, doing exports for interop as "extern C" (in general, because many other languages prefer it) is accepted anyways. Would you make the choice to add that complexity?