[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua loaders (was Re: Can a Lua module find out whether it is being required or dofiled?)
- From: Tom N Harris <telliamed@...>
- Date: Sat, 26 Sep 2015 05:13:50 -0400
On Wednesday, September 23, 2015 04:06:23 PM Jerome Vuarand wrote:
> 2015-09-23 15:15 GMT+01:00 Dirk Laurie <email@example.com>:
> > I have never understood what the manual means by "loader".
> > Is "mymod.lua" a loader for the module "mymod"?
> Yeah, in a sense. The loader (as defined in the require protocol) is a
> function, so the loader in your example is the function returned by
> loadfile("mymod.lua"), not the file itself (though whether these two
> things are distinct is a matter of point of view).
Stupid Lua Tricks!
local modulefunction, errormessage = load(module)
return modulefunction or errormessage
require[[ print "Hello World!" ]]
Why do searchers not follow the `nil,errormessage` protocol? If that were the
case the above could be simplified to