lua-users home
lua-l archive

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

2013/4/10 steve donovan <>:

> Remembering to return the module is one of those things
> a person forgets, especially if they're used to module.
> function newmod(name)
>   local mod = {}
>   package.loaded[name] = mod
>   return mod
> end
> local M = newmod(...)
> ...
> And then voila, no need to return M at the end!


Forgetting to return the module table is like forgetting to take your
cash out of the automatic teller machine: it's a waste, but you'll
discover pretty soon you haven't got it.

Messing around with package.loaded qualifies as obfuscated code.