[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules and require all
- From: Rena <hyperhacker@...>
- Date: Tue, 13 Nov 2012 11:59:26 -0500
On Tue, Nov 13, 2012 at 11:30 AM, Rapin Patrick <rapin.patrick@gmail.com> wrote:
>> -- program using _ENV
>> local a = 'local var'
>> do
>> local _ENV = require 'mod'
>> print(a) --> local var
>> end
>>
>
> A potential solution would be to introduce a new "global" or "unlocal"
> keyword, which would force the compiler to perform a global (_ENV) access,
> overriding the local scope of a variable.
>
>
> local a = 'local var'
> do
> local _ENV = require 'mod'
> global a
> print(a) --> from module
> end
>
My thought was "unset a", that would destroy the local a completely,
so future references would look for a global. But upvalues might make
this quite difficult to actually implement and use correctly.
--
Sent from my Game Boy.