lua-users home
lua-l archive

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


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...

Oh, good point, the default path works for the other form.
I was going to say that the nice thing about the init.lua approach is that it's a little more self-contained, but then I read Hisham's post.

Cheers,
Geoff