lua-users home
lua-l archive

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

Peter Hill:
> What situations do people tend to use globals for (as opposed to file-wide
> locals)?

Joshua Jensen:
> Why, things needing to be global, of course.  Shared data across different
> source files.  Shared functions.

Other source files defining globals is not very modular. I tend to take
advantage of the (rather unique) feature of Lua "dofile" that allows return

I'd much rather load a complex number package (for example) using:
    complex = dofile("complex.lua")

than the global version

The file "complex.lua" has:
  local c = {}
  function c.add ... end
  function c.sub ... end

  return c

Peter Hill.