[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: Josh Simmons <simmons.44@...>
- Date: Sat, 22 Oct 2011 10:18:53 +1100
On Sat, Oct 22, 2011 at 10:07 AM, Sam Roberts <vieuxtech@gmail.com> wrote:
> On Fri, Oct 21, 2011 at 3:59 PM, Philipp Janda <siffiejoe@gmx.net> 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?
- References:
- modules, require, magic, Eduardo Ochs
- Re: modules, require, magic, Javier Guerra Giraldez
- Re: modules, require, magic, Petite Abeille
- Re: modules, require, magic, Sam Roberts
- Re: modules, require, magic, David Manura
- Re: modules, require, magic, Mark Hamburg
- Re: modules, require, magic, Sam Roberts
- Re: modules, require, magic, Philipp Janda
- Re: modules, require, magic, Sam Roberts