lua-users home
lua-l archive

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


On Jan 23, 2010, at 1:57 PM, joao lobato wrote:

> Hello list
> 
> The in-do-end construct in Lua 5.2 compelled me to subscribe to the
> list (rather than simply
> browsing through the recent archives). Maybe this post should have
> gone to a pre-existing
> thread, in that case, please apologize the noise.
> 
> When I first read about "in <table> do <statement>+ end" my mental
> picture of it was "any
> variable reference in a function call inside <statement>+ that cannot
> be resolved locally will
> be looked up on <table>". A simple test and subsequent reading proved me wrong.

in-do-end really does suggest stack-based rather than function-based global scoping -- i.e., the dynamic-scoping proposal. setfenv when used with functions pretty well hammered home that environments were attached to functions. It was less suggestive about what was going on when used with stack indices.

Mark