[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Command line library load in Lua 5.2
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 2 Nov 2011 06:55:26 +0200
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