so, i used C++ namespaces in Crucible pretty heavily...
a typical way to address a very common symbol looks like this: crucible::core::memory::HeapBuffer. logically this makes sense to me:
crucibleis the overarching projectcoreis the name of the linkage unit (DLL, static library, or executable)memoryis the specific header file it comes fromHeapBufferis the symbol
but then i end up with ridiculous function declarations like this (contrived, but very representative) example:
template<typename T> requires crucible::core::convert::Convertible<crucible::core::string::String, T>
[[nodiscard]] constexpr auto join(crucible::core::memory::HeapBuffer<T> const &objects, crucible::core::string::String const &delimiter) noexcept -> crucible::core::string::String;
i also think [[nodiscard]], constexpr where possible, and noexcept where possible are all sensible defaults and should be added to every function declaration unless there's some reason they can't be. i think there's nothing to be done about these, but they contribute to the unnecessary line length and make it even more important to slim down the symbol names.
this problem is really getting to me, and i can only think of a few solutions, none of which really appeal to me:
- reduce the number of namespaces: practical, but it discards information that i think is valuable
- start using
namespace short = some::nested::long::ns;,using namespace some::nested::long::ns;, orusing some::nested::long::ns::ThingIWant;which feels brittle (especially in header files) - same as the last one, but put it into a
namespace internal { ... }or similar. i think this is my least-disliked solution, but it's still kind of wonky, and you still end up withinternal::Thinginstead of just the idealThing.
in other languages i think the namespace issue would be resolved by the import system, where you could both declare the requirement of some::nested::namespace::symbol and alias it to symbol in the same declaration, only for the current file (since in basically every other language the source for a single module is inside exactly one file), without leaking it to unexpected places.
what do you folks do to de-clutter your symbol references?

eggbug enjoyer