[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LUA_PATH and versions
- From: Andrew Starks <andrew.starks@...>
- Date: Thu, 15 May 2014 13:10:16 -0500
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