lua-users home
lua-l archive

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


Hello there!

This weekend I've tried the 5.1 package system for real for the first
time, and I've stumbled on a few issues which I describe below.
Hopefully they'll serve as insight for potential improvements on
future releases.

- For consistency, the path "./?/init.lua" should probably be included
  in the default package.path (and the equivalent for cpath). This allows
  using packages in local development directories the same way they'd
  be used when installed in system-level directories.

- It'd be nice if "requires" could tell the executed module where it was
  found somehow (e.g. _FILE).  Knowing where the module was found during
  its execution allows implementing location-specific behavior (e.g.
  read a template or whatever from the same place).

  I've managed to implement the feature by using:

    _FILE = string.sub(debug.getinfo(function() end).source, 2)

  But this seems valuable and simple enough to have as a standard
  feature of the module loading system.

- module() seems a bit tricky to deal with.  I've specifically stumbled
  upon the fact that it either hides the global environment, or it pollutes
  the module namespace (with package.seeall).  I've also missed the "import
  locality" common in other languages; in Lua, if one module requires
  something, everything else can see the same module.  I'm trying to
  invent some conventions to minimize these details, but it'd of course be
  awesome to have the standard mechanism dealing with it, as it'd encourage
  good practices by default.

Keep up the great work!

--
Gustavo Niemeyer
http://niemeyer.net