lua-users home
lua-l archive

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


On 03/31/2014 12:00 PM, Andrew Starks wrote:


On Sunday, March 30, 2014, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 31.03.2014 01:09 schröbte Tim Hill:

[...]

To my mind “the Lua way” is have as LITTLE policy as is practical.
The question, therefore, is really this: is it sufficiently useful to
have a policy-based method to manage global variable declaration to
justify it’s addition? Notice that this has nothing to do with HOW
such a policy is realized. This is because policies solve issues of
standardization, while the realization of policies involve issues of
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 they
all collide with 3rd party code such as libraries. I’ve had this
issue as well; it doesn’t really matter what you do with the existing
solutions, they only really work if you have total control of 100% 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!


[...]

—Tim


Philipp


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 dirk's fork).  

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 static analysis. 

Thank you, Internet! :)

-Andrew
I have something to cheer you up a little:
http://lua-users.org/lists/lua-l/2002-04/msg00177.html

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.

--
Thomas