lua-users home
lua-l archive

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



It seems like we ought to be able to implement a safeguard against global misuse by doing something like:

  function setglobal(i, v) print("no such local variable: '"..i.."'") end

and then explicitly calling:

   globals().globalvarname = value

when we want to set a global. This doesn't seem to work though.
Also, using a settable tag on the globals table doesn't work:

   local gtag = newtag()
settagmethod( gtag, "settable", function(t, i, v) print("no such local: '"..i.."'") end)
   settag(globals(), gtag)

Is there no way to override the setting of globals?

(Sorry if this has already been mentioned)

Steve