Enhancement Suggestion - Lazy Primitive Initialization
This behavior of Angelscript just bit me yet again, only this time it caused Bullet to crap itself. I have a double as a member variable that determines how much thrust is applied to an entity. However, because I left this value uninitialized in the base class, at random times I received the "Overflow in AABB" error, with no way to consistently reproduce the problem. It was actually a complete fluke that I discovered the source of the issue. These sorts of problems are one of the reasons that we use scripting languages. Therefore, I would like to recommend that primitive datatypes in Angelscript be initialized with a default value of 0 to mitigate these issues.
Having random behaviour due to uninitialized memory is definitely bad. I'll see what I can do about this.
However, I will not guarantee that uninitialized variables will always be cleared to 0 by default. This would require extensive changes and impact the performance quite a bit. Especially with loops, where the VM would have to repeatedly clear all memory on the stack for each iteration.
However, I will not guarantee that uninitialized variables will always be cleared to 0 by default. This would require extensive changes and impact the performance quite a bit. Especially with loops, where the VM would have to repeatedly clear all memory on the stack for each iteration.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Having random behaviour due to uninitialized memory is definitely bad. I'll see what I can do about this.
However, I will not guarantee that uninitialized variables will always be cleared to 0 by default. This would require extensive changes and impact the performance quite a bit. Especially with loops, where the VM would have to repeatedly clear all memory on the stack for each iteration.
Loops aren't as much of a problem as much as member and global variables are, because those are the ones we actually work with the most. And if it would take too much time only to have performance take a hit, then I guess we could actually take what we learn from C and initialize our variables in the first place.
The problem is if AngelScript has to keep track of the scope of local variables to guarantee that all variables are zeroed as they come into scope (e.g. in loops).
However, one-time initialization as memory is allocated shouldn't cause a lot if impact, and also shouldn't be difficult to implement. It will also solve your main problem, i.e. random behaviour for execution due to uninitialized memory.
However, one-time initialization as memory is allocated shouldn't cause a lot if impact, and also shouldn't be difficult to implement. It will also solve your main problem, i.e. random behaviour for execution due to uninitialized memory.
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
Popular Topics
Advertisement