lua-users home
lua-l archive

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


Oh now it's clear! thank you very much!! This is the kind of examples and justification I was looking for!

function make_counter()
  local x = 1
  return function() x = x + 1; return x; end
end

 
function read()
  return x
end

function write()
  x = 1
end

Since neither of these have any declarations, I would hope that they would behave the same way with respect to the x variable -- either both local (which makes read() an error) or both global, but in a language with "nonlocal" then read() is global while write() is local.


--
Andrea Vitali






_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org