On 03/31/2014 12:00 PM, Andrew Starks
I have something to cheer you up a little:
On Sunday, March 30, 2014, Philipp Janda <email@example.com>
Am 31.03.2014 01:09 schröbte Tim Hill:
To my mind “the Lua way” is have as LITTLE policy as is
The question, therefore, is really this: is it sufficiently
have a policy-based method to manage global variable
justify it’s addition? Notice that this has nothing to do with
such a policy is realized. This is because policies solve
standardization, while the realization of policies involve
efficiency and compatibility (and, dare i say it, elegance).
The OP points out that the problem with existing
implementations/work-arounds/hacks (choose your word) is that
all collide with 3rd party code such as libraries. I’ve had
issue as well; it doesn’t really matter what you do with the
solutions, they only really work if you have total control of
the source in your project.
That's not true. It's just that the `strict.lua` provided by the
Lua authors *as an example* does not handle that case (to keep
it simple, I guess). You can have each module author choose the
method he/she wants to use to catch unwanted globals, no policy
needed here at all. This is obviously true for static offline
approaches, and for the dynamic approaches I've thrown together
and attached a proof of concept based on the original
`strict.lua`. Use it via
require 'mstrict'() -- notice the extra pair of parentheses
in every file you want to. No third party modules are harmed in
the process. Global assignments at the top level still count as
declarations. Have fun!
Thank, everyone. My mind is changed and I've been educated. I
now see why things are the way that they are.
I said there err new keywords when I meant more operators. I
now understand that to be a very significant difference (from
I concede my points. Maybe as in "continue -> goto", there
might be some kind of tweak that brings about a bit more of the
flavor of what I was reaching for, with my thought.
But, your kind responses helped me understand much. I will
find some time in the next month to play with the world of
Thank you, Internet! :)
See, the Lua team was there already. For me it's a petty that they
dropped those ideas. I have myself a metatable on the globals to
support this stuff. But a general solution to such a basic problem
would be nice.