On Feb 26, 2018, at 10:01 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
You changed the rules first by monkey-patching 'require'. Why should
the undocumented 'package.loading' be a holy cow if the
well-documented 'require' has already been slaughtered?
just to be clear, patching require is to fix a bug.
package.loading function does not need to touch any lua c code.
It is just as easy to test against the userdata sentinel.
if mod.lua return false, require "mod" will set package.loaded.mod to false.
--> require 'mod' can potientially load mod.lua multiple times.
I read the original Roberto package proposal dated 9/17/2004,
it will not allow false (or nil) into package.loaded cache table:
https://marc.info/?l=lua-l&m=113878469246850&w=2
for some reason, translated c implementation is slightly different.
Since I am fixing require, I just use false as the sentinel,
and code package.loading function in lua instead of c.