Thursday, December 17, 2009

Lua and Non Related Changes

Lua will need some improvements and I hope that today I've made a half of image what changes will be needed. I'm still not 100% sure what changes will be but at least I know what are the most facing problems I will encounter.

The other change done this days is about how attributes worked to be identified and what can be the problems that persons might get using the old code. The tree of nodes can get attributes of any given type as long as they are registered. In fact that can make to appear a class of problems. One of the problem is that the conflicting names. NaroCAD used Integer, Real and Color names for storing specific values that may be too generic. This is really great as long as other person wanting to add their custom type will not colide with already defined types. Right now, because we did not write in C++, but in C#, there is a very simple way to create a type that do not collide: use the Reflection .NET API and picking the name and hashing from there. In the past there was a probability (very small, but it could) make that even you had different strings, the generated hashes may collide.

Right now, Type.GetHashCode() have no coliding value as is unique for type IDs. Also is really great because the code will not make you define a custom constant and to write some "magic code".
So to define in past your interpreter the code was like:
public RealInterpreter() : base(nameId) { }
static int nameId = AttributeInterpreterFactory.Register(InterpreterNames.Real);

Right now the code is:
public RealInterpreter() : base() { }
And the registering can be done anywhere else just in case of using deserialize/save to disk and no associated string constant (InterpreterNames.Real) needed.

No comments: