lua-users home
lua-l archive

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



On Apr 7, 2014, at 9:24 PM, Philipp Janda <siffiejoe@gmx.net> wrote:

Am 08.04.2014 05:01 schröbte Tim Hill:

Assuming we are not talking about syntax sugar, what could we do better?

Let's talk about pure Lua modules first, because that should be easier.

1.  A user downloads and extracts a zip or tarball containing some directories and/or files.
2.  The user navigates to the "module root directory" in the extracted directories, and copies all files and subdirectories somewhere into a directory that's in your `package.path`. On Windows that probably would be the directory where Lua is installed, but for non-admin users we could add another entry to `package.path` that points somewhere into the users home directory. Do we need support for a HOME or USER variable in the `package.path` templates? I think even Unix users would benefit from a `~/.lua/?.lua` entry in the default `package.path`. We probably also need some way to tell the user what/where the "module root directory" is.
3.  `require` should just work, then.

Now for C modules:

1.  The user could avoid many problems by downloading a ready-made binary. For Windows the LuaDist project provides such downloads. The downside is that have to take care to compile your own C modules or your own Lua binary in a compatible way. You need (at least) the same C runtime and the same Lua dll. For Linux etc. there are no binary downloads at the moment (other than in your favorite package repository), and I'm not sure how compatible a Linux binary (e.g.) will be across distros ...
2.  You put the binding dll somewhere into `package.cpath` (again on Windows probably the Lua directory). We would probably benefit from a user-local default location here as well.
3.  You put the library dll somewhere into your PATH (on Windows) or LD_LIBRARY_PATH (on Unixes). On Windows that could also be the Lua directory if the user put it into the PATH (or maybe the Windows directory?). On Linux your package manager takes care of this for you, or you install the library somewhere into `/usr/local`.
4.  `require` should just work, then.

If we consider building C modules things get complicated very quickly unless we dictate compiler, flags, build tool, etc.

User-local entries in the default `package.path`/`package.cpath` seem to be useful. (Although one should assume that a programmer is able to set an environment variable once.)

What else can we do to make using external modules less fragile (I'm not sure how much `require` can contribute to that)?

Maybe we should concentrate on making LuaDist/LuaRocks easier to install instead (graphical installer, include mingw compiler in the package, etc.)?!

Well I think your post answers your own question. There *are* a lot of steps involved and there *is* a lot of platform variability. It’s like the difference between installing an iPhone app and the other (pre-iPhone) competitors: all the others were far too “techie”. Sure, most Lua users *can* navigate all the intricacies, but why should they have to?

—Tim