[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: package.path doesn't contain './?/init.lua'
- From: David Manura <dm.lua@...>
- Date: Mon, 27 Apr 2009 21:09:17 -0400
On Mon, Apr 27, 2009 at 4:15 PM, Geoff Leyland wrote:
> The default package.path contains './?.lua', but not './?/init.lua'.
> Obviously, it's easy to add, so there's no problem, but I often find myself
> adding it. Any reason it's not there by default?
Perhaps we should instead ask why init.lua it not eliminated entirely.
It is not necessary[1], and I think it complicates things[2]. Module
authors need to decide which form to use, and it's near certain that
different module authors will choose different conventions. Module
users or Lua distributions, when adding a directory to the Lua search
path, may need to add both forms in general, though omitting the
latter might usually work or might appear to initially work. It also
opens the ambiguity where ".../a/init.lua" could represent the module
"a" or a module actually named "a.init". Finally, it makes module
search errors longer for the end-user:
$ lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "a"
stdin:1: module 'a' not found:
no field package.preload['a']
no file './a.lua'
no file '/usr/local/share/lua/5.1/a.lua'
no file '/usr/local/share/lua/5.1/a/init.lua'
no file '/usr/local/lib/lua/5.1/a.lua'
no file '/usr/local/lib/lua/5.1/a/init.lua'
...
[1] http://lua-users.org/lists/lua-l/2008-01/msg00128.html
[2] http://lists.luaforge.net/pipermail/kepler-project/2007-May/000854.html