lua-users home
lua-l archive

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

On Sat, Oct 22, 2011 at 10:07 AM, Sam Roberts <> wrote:
> On Fri, Oct 21, 2011 at 3:59 PM, Philipp Janda <> wrote:
>> On 21.10.2011 20:49, Sam Roberts wrote:
>>> [...]
>>> I'd say the single biggest problem with losing module is that we have
>>> to port everything to 5.2, and do it in a way that also works for 5.1
>>> (which will be here a long time).
>> Just use the proposed module-less module system -- it will work for Lua 5.1
>> and 5.2 (no matter what is decided for the future of "module")!
> You say "just use", but you mean is "rewrite everything".
> You seem to be making the point that it is possible to write modules
> in 5.2, but I don't dispute that, not does anyone else.
> I just don't want to rewrite everything for dubious advantage.

You say rewrite but you mean s/^function /function M./c

>> The proposed common idiom for 5.2 is:
>> local M = {}
>> function M.f() end
> Like prepending M. to the start of every function defined in my modules.

Yes the onerous task of adding two extra letters is similar than that
of designing a reusable API.

>> You could also write:
>> local protocol = { tcp = require"protocol.tcp" }
>> The point is: The user of the module has the choice!
> A module has one definition, and many users, your proposal means
> modifying every use of the module to construct the namespace implicit
> in the module name. Of course, instead, I'd rewrite require to do
> this.
> Sam

You're completely insane if you'd monkey patch standard functions for
a small convenience such as this. How many of your modules have such
important nesting?