Re: Module system curiosity
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Module system curiosity
- From: Mark Hamburg <mark@...>
- Date: 2010年5月30日 11:26:19 -0700
The simple fix is to change the module function so that it doesn't set any globals but rather just populates a registry of loaded modules. That way, in your example, all that require "lpeg" would do is:
* Load the lpeg module if not alreaded loaded and store a reference to it in the registry
* Return a reference to the caller of require -- you would now call it as:
local lpeg = require "lpeg"
If you want to re-export lpeg from within your module, you are free to do so, but it doesn't seem like something you would ordinarily want to do.
This does make require a bit more cumbersome in interactive mode, however.
Mark