gmqcc icon indicating copy to clipboard operation
gmqcc copied to clipboard

namespaces

Open graphitemaster opened this issue 12 years ago • 3 comments

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.

graphitemaster avatar Dec 02 '12 23:12 graphitemaster

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;.

Blub avatar Dec 03 '12 10:12 Blub

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.)

Blub avatar Jan 09 '13 21:01 Blub

How should we handle fields declared in namespace outside of -std=gmqcc? Should we warn? Are they then only visible inside the namespace?

Blub avatar Jan 17 '13 09:01 Blub