lua-users home
lua-l archive

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


> I have remarked an unexpected behaviour (to me) of the lua loadfile 
> function. It returns a function, but it seems this function does not 
> herit the global table from the caller of the loadfile function. Is it 
> on purpose ? Which global table is assigned to it ?

Currently, loadfile (and loadstring) always returns a function with the
default global table (that is, the one used by the C functions). It
is very easy to change it before running the chunk, so that all functions
created by the chunck already get the new table:

  local f = loadfile"..."
  setglobals(f, t)
  f()

But we can change that.

-- Roberto