lua-users home
lua-l archive

Is this guaranteed to generate a new function every time?

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


If I have this:
local t = {}
local another_function(wrapped, ...)
 print(t[wrapper])
end
local function wrap(something_important)
 local function wrapper(...)
 return another_function(wrapper, ...)
 end
 t[wrapper] = something_important
 return wrapper
end
Is it guaranteed that 2 calls to wrap() won't cause weird fucked-up semantics? E.g. can I do this?
local wrap1 = wrap(1)
local wrap2 = wrap(2)
wrap1() --> prints 1
wrap2() --> prints 2
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.

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