lua-users home
lua-l archive

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


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