[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Command line library load in Lua 5.2
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 2 Nov 2011 15:54:02 -0200
> 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.
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(mymod.foo(10))"
Not polluting the global namespace does not mean a complete prohibition
of ever creating a global.
-- Roberto