[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: package.seeall and strict conflict
- From: David Manura <dm.lua@...>
- Date: Mon, 17 Aug 2009 21:52:10 -0400
On Mon, Aug 17, 2009 at 4:29 PM, Jim Jennings wrote:
> On Thu, 13 Aug 2009 00:59:40 -0400, David Manura wrote:
>> Let some module A in a program do require "strict" and some other
>> module B in the program do module(..., package.seeall). Now, strict
>> behavior is applied to the implementation of B. This may be desirable
>> or it might not be.
>
> In my opinion, this is *not* desirable. If A is written using
> "strict", then "strict" should apply only to A, and not to modules
> that use A.
I agree. For example,
require "strict" "globals"
where require "string" returns a function that when called updates the
environment of the caller (e.g. a private environment).
> If there is interest, I could find a place to post my implementation.
> (On Luaforge?)
I'm interested. You may also post a page on the wiki (e.g. if you
feel it's not yet ready for LuaForge).
> But once you
> protect the metatable, you break a useful (and widely used) feature of
> Lua, which is the ability to change the metatable of the environment.
Though you can still change the environment (e.g. proxy the old environment).
> Here's a quick example using Lua Lanes 2.0.3, which I installed
> unmodified. After playing with it, I wrote this declaration [3]:
>
>> structure.declare { name="lanes";
> open={"_G", "package", "table", "string"};
> environment=[[ require("lanes");
> return lanes ]];
> }
>> require "lanes"
>> dofile "lanes-test.lua"
What is the semantics of "open" ? Does this add the listed symbols to
the private environment of the lanes module?