lua-users home
lua-l archive

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


On 7.8.2010, at 6.10, Mark Hamburg <mark@grubmah.com> wrote:

-- Define a module with functions foo and baz:

local M = { }

function M.foo()
   --
end

function M.baz()
   --
end

return M


This hardly seems particularly bizarre and it doesn't rely on tricks with environment to change global assignments into exported values.

Mark


Indeed. Honestly this should become the recommended practice or the new 'policy', if you will. It's as explicit and simple as it gets. Although it takes a bit more typing because you'll need to prefix function calls inside the module with 'M.' But I actually like it that way because it's clear where those function calls lead to.

Petri