lua-users home
lua-l archive

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


2011/11/1 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> Now that we are all adjusting to the new way of handling modules, the
>> '-l' command might be extended to allow this:
>>
>>     lua5.2 -l mymod=long_and_unwieldy_module_name -i
>
> mymod would be a global? ie, that'd be translated to
>        mymod = require"long_and_unwieldy_module_name"
>
> In that direction lies a suggestion that modules create globals,
> something that has already been beaten to death here (we hope)...
>

On the contrary, my point is precisely that all the new good habits of
avoiding pollution of the global namespace is undermined by the Lua5.2
interpreter itself.

The present behaviour is this:

~~~~ mymod.lua
return 42
~~~~

    $ lua5.1 -l mymod -e "print(mymod)"
nil

    $ lua5.2 -l mymod -e "print(mymod)"
42

I.e. the global name is not created by the module, but by the Lua5.2
standalone interpreter.

Dirk