Re:Problems of C, and how Zig addresses them
by naasking on Monday July 03, 2023 @04:52PM
(#36578661)
A prefix and a namespace aren't really that different in practice.
Re:Problems of C, and how Zig addresses them
by staunton on Monday July 03, 2023 @06:31PM
(#36579669)
They are different. Namespaces are syntactically enforced and you can opt-in or out to names. To have syntactically validated qualified access.
Naming might go well and have the same utility, but you never know what evil things are going on in all those headers, redefining each other's symbols and yours.
Re:Problems of C, and how Zig addresses them
by naasking on Monday July 03, 2023 @11:23PM
(#36581805)
You seem to be focusing on specific problems with C/C++. I don't really care about that, all I'm saying is that prefixing names are equivalent to placing them within a namespace, in practice, and theoretically come to think of it. You can easily define a bijection between namespaced symbols and prefixed symbols. Requiring the full prefixes are simply a tad more verbose, essentially equivalent to using a fully qualified name for symbol.
The only sane way to deal with name collisions is either to use C stdlib types in library APIs (e.g. uint8_t), or use a library specific prefix (e.g. mylib_u8) - which is of course even more awkward than just using the standard uint8_t.