lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I still think the main problem is non-intended assignment to globals,
which creates hard-to-find bugs. 

And I fully agree with that, and this applies to config files as well. Missspelling of variables cause silent missconfigurations.

As posted, one can fix that with a metatable to _G. 

The one "issue" (under quotes) I see is a more general terms, the dialectic of Lua of wanting to be a simple and newcomer friendly language on the one hand, denying convenience operators like ++, ?:, etc. that some think look scary, indexing by 1 and the hard to get/understand semantics to fix globals via a metatable to _G on the other hand (or metatables in general, goto statements, etc.). And no I have no idea how to "fix" this, it's just a result of the way Lua grew over the decades with diffferent foci.

Or to say it differently: personally I'm all fine the way globals are handled or how I can fix it with a metatable to _G. IMO it just should be simpler for people that don't want to embrace the shenanigans of metatables which is a hugh requirement for someone who is supposed to feel 0-indexing too unnatural and can't handle the ?: operator.