lua-users home
lua-l archive

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

On 21 Nov 2013, at 21:59, Marc Lepage <> wrote:

> Is a module that is a function (not a table) a reasonable thing? Is it a common idiom (in this case)? Are there alternatives?

Modules can return anything, or nothing (require converts this to true).

I've toyed with this idea as it does feel a bit silly to return a table with one function it it, but I always decided against it because:

1) I'll never be able to remember which modules return tables, and which return a function
2) I can guarantee that at some point in the future, that module which currently only has one function will need another, and the rewrite will be horrific if not returning a table.