[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: proposal (RE: Making vars local by default)
- From: Jean-Claude Wippler <jcw@...>
- Date: Thu, 31 May 2001 22:02:59 -0700
Tom _ <tom7ca@yahoo.com> wrote:
>> Having to switch to a new
>> assignment operator like ":=" would be much more
>> annoying.
>
>I'm not suggesting switching. I'm suggesting
>adding the ":=" operator (and possibly a "global"
>keyword for use with ":=" that does not otherwise
>interact with "="; see my other posting).
>
>Nobody who doesn't want to would have to switch to
>using ":=". Code that uses "=" would continue to
>work and seamlessly work with code that uses ":=".
>"x := y" would simply be a shorthand for "put
>'local x' at the beginning of the function and
>write 'x = y'".
That's not the whole picture: from then on both coding styles would start
to proliferate and gradually become part of libs, tools, etc... :(
Assignment is not really the issue, let's please not overload that (quite
standard) concept.
I really don't see what the big deal with globals is. In large programs,
I find that much "variable" accesses happen to objects anyway, not locals
on the stack.
Have you considered the following:
function blah(...)
local v = {}
...
v.a = ...
... = v.b
...
end
Would that, plus "test/undefined.lua" perhaps, (at least partially)
address your concerns?
-jcw