5 ms·
It would be fine, I think. Just create the variable in the scope you want it, then assign to it somewhere else. If you get it wrong, you get it wrong, and there
by to3m 12y ago
It would be fine, I think. Just create the variable in the scope you want it, then assign to it somewhere else. If you get it wrong, you get it wrong, and there's scope for weird bugs from that - but the effect is at least localized, lexically.
(Of course, the right thing to do is have explicit variable declarations...)
- ufo 12y agoLocalized bugs are still bugs. Better always require a variable declaration and have no defaults. Usually languages use local-by-default to avoid the need for variable declarations in the first place (in misguided manner, IMO) instead of doing so to avoid globals. This page might be interesting, btw: http://lua-users.org/wiki/LocalByDefault http://lua-users.org/wiki/LocalByDefault