• Create Account

### #ActualJake Albano

Posted 30 January 2013 - 10:39 AM

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.

### #4Jake Albano

Posted 30 January 2013 - 10:39 AM

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.

### #3Jake Albano

Posted 30 January 2013 - 10:38 AM

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.

### #2Jake Albano

Posted 30 January 2013 - 10:38 AM

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.

### #1Jake Albano

Posted 30 January 2013 - 10:37 AM

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.

PARTNERS