lua-users home
lua-l archive

Re: lexical scoping

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


> for k, v in tab do
> local v = v
> actors[k] = function (x) act_on(v, x) end
> end
Sounds like it'll be great. I'm looking forward to reading about it in more
detail. 
k and v locals in the block enclosing these 4 lines of code, right? So I'm
a little confused as to why "local v=v" is needed.
Wouldn't v just be found as a local of the next block up and have the
correct value to be bound when actors[k] is defined? Why does it have to be
copied to the immediately enclosing block?
Russ 

AltStyle によって変換されたページ (->オリジナル) /