[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: modules, require, magic
- From: Josh Simmons <simmons.44@...>
- Date: Wed, 19 Oct 2011 08:21:10 +1100
On Wed, Oct 19, 2011 at 6:48 AM, Doug Currie <firstname.lastname@example.org> wrote:
> On Oct 18, 2011, at 1:53 AM, David Manura wrote:
>> On Mon, Oct 17, 2011 at 1:00 PM, Sam Roberts <email@example.com> wrote:
>>> Now we are trying to support two ways, check out this code at about line 60:
>> That's ugly, though not necessary either. I would, like Luiz, avoid
>> using both _ENV and 'module' for module definition.
> Of course it's not necessary for new modules. I avoid both _ENV and 'module' for any new modules I create. The challenge is trying to maintain maximum compatibility with uses of existing modules, such as lunit, in large code bases, with both Lua 5.1 and 5.2.
It's really not that hard though, replace the module call with a table
creation, do a find and replace of non-local definitions prefixing
with the table name and then return the table at the end. You now
support everything. Calling code just needs to change from require 'a'
to local a = require 'a'.
What's more you don't have to do it all at once either, a module at a
time works fine.
- 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, Doug Currie