gmqcc
gmqcc copied to clipboard
namespaces
For projects like xonotic where there is a lot of gamecode, I think it would be nice to see namespaces for organizing code a little better. I expect the process to work exactly like it does in C++ something along the lines of:
namespace name {
{{{code}}}
}
and then for importing individual functions and variables into the global scope:
using namespace::ident;
This would allow for a hierarchies, server code in namespace server for example, while client in another namespace.
Definitely. We also need to solve the entity-field namespace problem. Currently you cannot use fieldpointers in -std=gmqcc
because the fields themselves are not in the global scope. We should have a builtin entity
namespace so to assign a fieldpointer to the field origin
you'd use fptr = entity::origin;
.
Reminder:
We came to the conclusion to reserve a namespace named reserved
. This rids us of messes like C11's names (_Alignof
vs sizeof
vs reserving names starting with 2 underscores... it's a mess, it's silly, and quite frankly, it's pretty fucking stupid. As for possible clashes with existing code: I personally would have rather used _Alignof
in code than alignof
because I'd have EXPECTED the standard to reserve the alignof
keyword at some point. So fuck you.)
How should we handle fields declared in namespace outside of -std=gmqcc
? Should we warn? Are they then only visible inside the namespace?