Is this guaranteed to generate a new function every time?
[Date Prev][
Date Next][Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Is this guaranteed to generate a new function every time?
- From: "Soni L." <fakedme@...>
- Date: 2016年7月31日 22:29:20 -0300
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.