Sign in to follow this  

Static / Type members?

Recommended Posts

TechRogue    722

I've recently gotten in the habit of using static member constants and the named constructor idiom to improve readability of my C++ code. For example:


Vector3 vec = Vector3::Up;
Matrix mat = Matrix::Identity;

if (getPosition() == Vector3::Zero)


I think the addition of constant class members to Angelscript would be really helpful. Something like this -- in C++:

class MyCType
    static const int MyConst;


engine->RegisterTypeProperty("MyType", "int myConst", &MyCType::myConst); // just like RegisterGlobalProperty


...and in Angelscript:

int foo = MyType.myConst; // properties accessed through the type, not an instance


Is there any chance we'll see a feature like this? I'd be willing to try and implement it myself, but I have no idea where to start.

Edited by Jake Albano

Share this post

Link to post
Share on other sites
WitchLord    4677

Static class members and constants are on my to-do list, but currently with a very low priority as it is really just syntactic sugar. They are after all nothing more than global variables and constants declared in the namespace of the class.


I haven't begun thinking about how I want these to be stored or registered in AngelScript, but it is quite possible the namespace feature will come in handy here, by simply allowing the class name to be used as namespace identifier too. 

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