🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

AS 2.0 : RegisterGlobalProperty error : Why only const primitivetypes ?

Started by
2 comments, last by WitchLord 19 years, 4 months ago
I used to declare a global property ioScriptEngine->RegisterGlobalProperty("const Texture NO_TEXTURE", &ASNoTexture); In AS 2.0 it craps out saying "Only primitives may be declared as const". Why is this ? I really wouldn't want anyone to do something like NO_TEXTURE = MyCheckerboardTexture - and screwing up the default :)
_-=[ "If there's anything more important than my ego around, I want it caught and shot now." ]=--=[ BeatHarness ]=-=[ Guerrilla Games ]=-=[ KillZone ]=-
Advertisement
The problem was that the script language wasn't able to guarantee that a const object really was constant. Object methods, or overloaded operators could still alter the object. Because of that I decided to remove the const modifier for objects until I can implement a way that guarantees object constness (does that word exist?).

The way to implement it would be with adding the const modifier for object methods as well, e.g. CLASS::Method() const. The library could then disallow calls to non-const methods for constant objects.

I want to add const for objects again, but it's not very high on my priority list. Maybe I need to increase this priority again.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote: Original post by WitchLord
I want to add const for objects again, but it's not very high on my priority list. Maybe I need to increase this priority again.


Please do, I really don't trust scripters not to change my globals :)
(And if they do they f**k up the behaviour entire program afterwards ;))
_-=[ "If there's anything more important than my ego around, I want it caught and shot now." ]=--=[ BeatHarness ]=-=[ Guerrilla Games ]=-=[ KillZone ]=-
I think I have a pretty easy solution to this. If I'm right I will be able to add constant objects already for 2.1.0.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement