[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA_PATH and versions
- From: Andrew Starks <andrew.starks@...>
- Date: Thu, 15 May 2014 13:33:16 -0500
On Thu, May 15, 2014 at 1:20 PM, Thijs Schreijer
<thijs@thijsschreijer.nl> wrote:
>
>
>> -----Original Message-----
>> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
>> Behalf Of Andrew Starks
>> Sent: donderdag 15 mei 2014 20:10
>> To: Lua mailing list
>> Subject: LUA_PATH and versions
>>
>> Hey all,
>>
>> With syntactic additions (`//`, `>>`, etc) in Lua 5.3, shimming
>> modules is going to be more involved. Module writers will most likely
>> need to adopt a functional version of these operators, or have code
>> that does:
>>
>> ```lua
>> local my_mod = {}
>> my_mod.math_stuff = require(VER == '503' and 'my_mod.math_stuff_53" or
>> "my_mod.math_stuff_5X")
>>
>> ```
>>
>> I think this won't be as compromise-free as it was in 5.1->5.2.
>>
>> I have observed other systems that provide specificity controls using
>> directory structure, TeX being one example. Lua is the same, but it
>> doesn't use this facility for versioning. Is there a possibility that
>> this could be changed, given the coming need to do so?
>>
>> As an example, assume `lroot` is the system's root tree for lua
>> modules. Consider the following `package.path`:
>>
>> lroot/5.3/?.lua;lroot/5.3/?/init.lua;lroot/?.lua;lroot/?/init.lua;./?.lua;./
>> ?/init.lua
>>
>> I write `my_mod` that works fine with Lua 5.1, 5.2 and 5.3, except
>> that I want to take advantage of some things in 5.3. I can organize it
>> like so:
>>
>> root/my_mod/init.lua
>> root/my_mod/my_math_funcs.lua
>> root/5.3/my_mod/my_math_funcs.lua
>>
>> I've added this to my own development environment, but I haven't had
>> much time with it. So far so good, though. I can have multiple Lua
>> versions pointing at this same tree structure and modify the version
>> specific files in their own paths. It works with 5.1 and 5.2, as well
>> (LUA_PATH_52, etc).
>>
>> If this layout were prescribed for 5.3, it would make the above
>> example possible, even for deployment, and those modules would still
>> work for 5.2/1. It does nothing for module files that need to
>> prioritize 5.2/1 over 5.3, although a shim to require/package.path
>> could be sandboxed and used...
>>
>> I'm sure there are other ways to do the same and I don't mean to post
>> this as *the* way. It seemed simple enough and hopefully it's worth a
>> discussion.
>>
>>
>> Thanks!
>>
>> -Andrew
>
> Though I'm on Windows, and think the proposal could work, I also would probably stick with my current setup to have complete separate Lua installations for different versions (5.1 and 5.2 currently), each with their own module trees (LuaRocks trees) and its own LuaRocks installation.
> There is some overlap, but it makes it easy to keep things separate. Mixing will probably cause some severe troubleshoot headaches down the road.
>
> My 2cts
> Thijs
>
>
Would the idea be less confusing if the trees were more separated? Such as:
lua/mymod/init.ua
lua53/mymod/my_math_funcs.lua
?
I may have a stronger distaste for duplicate files and/or shim code
than you do, relative to more complicated directory structures. :)
-Andrew