lua-users home
lua-l archive

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

Hi all,

is there a way do execute dostring in Lua on the 'local' level? The example
goes like this:

a = 0; -- global 'a'

function test()
  local a = 0; -- local 'a'
  dostring("a=1;"); -- now dostring will set global 'a' to 1 just as there
were no local 'a'
  print(a); -- this will print 0, since local 'a' has not been touched

print(a); -- this will print 1, since dostring did set the global 'a'

Maybe this behavior is intentional, but in this case I would feel good if
someone would explain to me why it is so.

Roman Vanicek