Re: [GD-General] Scripting Systems
Brought to you by:
vexxed72
From: Brett B. <res...@ga...> - 2004-01-31 02:26:36
|
> Run-time is the only way to do it. Lua is a dynamically typed=20 > language, and since it doesn't even comprehend the idea of user=20 > defined types, "type checking" is kind of a no-op. =20 >=20 > What we'd need is a preprocessor that uses a convention where any=20 > uninitialized element accessed out of a table constructor or=20 > declaration is definitely bad. >=20 > v =3D { x =3D 0, y =3D 0, z =3D 0 } > v.zz =3D 3 --<< BZZZT! > Idea 1 A hack to be sure, but I could trap the __index error and do some sort = of "spell checker" against known elements, starting with the locals and = working my way upward. If it finds a recommended match (within some sort = of error metric) it changes it and keeps going. If I have a debugger it = could pop-up with the suggestion and allow me to accept or choose = another symbol and optionally modify the source for me to correct the = problem. Without a debugger it could output a log that looks like = preprocessor logs showing the error, line number, etc. As long as there = is an option to enable/disable the feature, it would probably fix like = 90% of the errors. Idea 2 Based upon the concept of automated unit testing, I could load the = function to compile, generate a unit test for each function, compile and = load both of them, and run the unit test against it. Failures could do = something like Idea 1 above and when fixed is written to disk (as an = obj). This gives you a Lint-like system and since we compile each = function as an object, incremental build will keep the performance = acceptable. Plus it has the ability to interactively fix problems. Anybody tried this? This sounds pretty workable to me. Brett |