Sign in to follow this  
WitchLord

AngelScript namespaces

Recommended Posts

WitchLord    4677
I just finished the initial implementation of namespaces in AngelScript. It is already working well, but I'm quite sure there are a lot of things that I missed. I do not want to hold off on releasing version 2.22.2 until I can try to think of and implement all possible tests needed to make sure namespaces work in all concerns.

So, I'm asking for a little help in validating the new functionality. Those that have plans to use namespaces in your projects should definitely try the latest version from the SVN (currently at revision 1130) and try to use them as you had intended.

Those that do not plan to use namespaces may also want to give it a try anyway, just to make sure nothing got broken in the implementation, though my regression tests say that everything else is working just fine without any negative impact.


Namespaces in AngelScript work pretty much as in C++, except I haven't implemented the 'using namespace' feature yet, so when referring to symbols from other namespaces it is necessary to explicitly write out the namespace.

Nested namespaces work as well, but currently a child namespace doesn't automatically see the symbols in the parent namespace, so here too is it necessary to explicitly inform the parent namespace.

[code]
namespace A
{
int a = 0;
void function() { a++; } // referring to symbols in the same namespace doesn't require scoping
}
void main()
{
A::function(); // referring to symbols from other namespaces require explicit scoping
}
[/code]


For future releases I'll continue to work improving the namespaces with 'using namespace' feature, and implicitly seeing parent namespaces, etc. Namespaces also provide a stepping stone for adding support for static members in classes as well as declaration of enums and subclasses as children of classes.

However the real reason I wanted to implement namespaces is that I plan on allowing the application to define access masks on them, thus allowing the application to control which modules may or may not use specific namespaces. This will make it possible share both code and global variables in a controlled manner between modules.

Regards,
Andreas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this