Re: changes in 'require'
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: changes in 'require'
- From: Diego Nehab <diego@...>
- Date: 2005年7月14日 00:14:48 -0400 (EDT)
Hi,
One one hand, that trick of using extra loaders is cute. On the other
hand, it breaks the idea that loaders only return a function that, when
called, opens a module (that is, loaders have no side-effects).
One idea is to have a way for a loader function to "fail" after running
(for instance returning false). Then the "load_ParentSearch" would
return a file, but that file when called would return false, meaning
"keep trying". But that idea subverts the whole current structure
of require ;)
One way to make this less subversive is to say that a loader's job is to
actually load a package into Lua, not simply obtain a function to be
invoked by require(). With the change, require would check _LOADED[name]
to see if a given loader succeeded.
I actually prefer this.
[]s,
Diego.