lua-users home
lua-l archive

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


RLake@oxfam.org.uk wrote:
>
> >   for k, v in tab do
> >     local v = v
>
> I think this means I have to go through a bunch of my code, adding
> local x=x
> wherever I find %x.

Hmm... there are two other possible solutions:

a) just define that the iteration variables of the for-loop are
instantiated for each iteration of the loop.  That way you always
get the behavior as if a "local k,v = k,v" is present.  Or,

b) just keep the %-syntax for upvalues to get the value the names
had at function declaration time.

> I actually quite liked the fact that Lua does functional (in the
> functional programming sense) closures. I'll miss it -- but I guess
> I'm in the minority.

The upvalues have some nice properties.  But if Roberto gets full
featured closures without performance sacrifices I would prefer them.
They are much more powerful.

Ciao, ET.