lua-users home
lua-l archive

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


> That is similar to what we are thinking. A global keyword to declare
global
> variables, and a mode that demand explicit declaration of all variables
> that get *assigned* (not used; otherwise we sould have to declare every
> global function that we call... Or should we?). (Maybe the "global"
> declaration itself may work also as a switch for strict declaration mode.)

    This sounds good to me.  I'd be happy to declare globals when they
are created.  I keep wanting to do it out of habit anyway. :))

    What I'd *really* like is to write access to local variables in
outer scopes.  The reason for this is that I want to allow for
executing chunks via dofile() that contain only local variables and
functions, which are therefore deassigned automatically at the end
of execution of the chunk.  I can imagine situations where large
chunks are executed that leave lots of new stuff in the global
environment.  My only option at the moment is to use globals
and put cleanup code at the end of the chunk that sets unwanted
global variables and functions to nil.

    The 4.0 manual says that a function cannot access a local
variable in an enclosing function "since such variables may no
longer exist when the function is called."

    Where would they go?

    An easier way to declare a local function would be nice too.
Well, local f = function() is easy, but I'd prefer local function f();