lua-users home
lua-l archive

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

>> I.e. the global name is not created by the module, but by the Lua5.2
>> standalone interpreter.
> Option '-l' would be essentially useless if it did not create the
> global.   It is intended to be used in interative mode and with the -e
> option: $ lua5.2 -l mymod -e "print("

I'll grant that the global is useful in that context.

But '-l' is not useless without the global.  Lua 5.1 does not set it.
Yet nothing forces you to use only modules that set globals 5.1-style.
 It's perfectly OK to use modules that return tables 5.2-style.  Just
say `local mymod=require "mymod"`.  This works nicely with '-l',

* option `-l` adds an item to package.loaded
* `local mymod = require "mymod"` in the program picks up the module
loaded with `-l` instead invoking the package search mechanism.

The original proposal did not spell out that `-l
mymod=mymod_123_alpha_rc3` creates or replaces an entry in
package.loaded for `mymod` rather than for `mymod_123_alpha_rc3`, but
preloading a specific version of a required package would be a useful
application for it.