lua-users home
lua-l archive

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


On Mon, Apr 14, 2014 at 2:03 AM, Enrique Garcia Cota <kikito@gmail.com> wrote:
> Hi there,
>
> I've written a series of articles about building Lua modules - it's here:
>
> http://kiki.to/blog/2014/03/30/a-guide-to-building-lua-modules/
>
> I would appreciate any feedback or comments on it.
>
> Thanks and best regards,
>
> Enrique ( kikito / @otikik )

Looks pretty thorough, good job!  The only thing I saw that might be
worth mentioning is some modules monkey-patch globals, and should only
be run once -- but they export/expose nothing so they return boolean
'true'.  You can return anything in a module of course -- the value
becomes referenced from package.loaded.module_name = <return value>.
If a module returns false or nil, I believe it will be loaded from the
file on every require().