lua-users home
lua-l archive

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

On 31 July 2014 01:23, Dirk Laurie <> wrote:
What I have done in some of my modules is to make them
return two values. Then `require "mymod"` only accesses the
public part, but `mymod, private = dofile"mymod.lua"` also
returns a table containing some local functions, cached
while they were visible. Then `lunit` or a similar tool can test
`mymod`, and some special-purpose tool that I have control
over can test `private`.
Love it. How did you stumble across this idea? :)
Previously I'd done things like define a global _TEST, and changed what I export depending on it's value. But I always hated it.