lua-users home
lua-l archive

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


> According to Luiz the main reason for current behavior is
> that in case of opposite it would be necessary to declare
> all functions as global. Probably the design of Lua does
> not allow to determine variable scope by the block where
> it is declared. It's a pitty because in my opinion it would
> be very nice solution - if a function is defined in global scope,
> it exists until global scope is destroyed and if a function
> or a variable is defined in a block, it exists until execution
> of the block reaches its "End".

I think this could not be easily done due to the fact that
a boolean value can be nil, which also means the variable
doesn't exist in the globals list. The interpreter would
not be able to distinguish between a global initialized to
nil then set in a function, and a local variable of that
function.

-- 
Lyrian