[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Indirect function call
- From: Bernd Eggink <monoped@...>
- Date: Fri, 06 May 2011 15:12:10 +0200
Hi all,
I'm new to Lua and presently trying out some things. I'm especially
interested in indirect access to variables and functions. No problems
with variables, but the following puzzles me:
--------------------------------------------------
function afunc(x)
print("afunc(" .. tostring(x) .. ") called")
return x
end
function indirect(str)
local result = loadstring(str)()
print(tostring(result))
end
x = 42
indirect("afunc(x)")
--------------------------------------------------
The output is:
afunc(42) called
nil
Can anybody explain why the output is nil instead of 42?
Thanks,
Bernd
--
Bernd Eggink
http://sudrala.de