lua-users home
lua-l archive

Re: [Proposal] _LOCAL was: Re: how to call a local function by its name?

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


On Mon, Jun 8, 2015 at 9:02 PM, Parke <parke.nexus@gmail.com> wrote:
> On Mon, Jun 8, 2015 at 7:37 PM, Coda Highland <chighland@gmail.com> wrote:
>> Worse, [Python's local-by-default] makes upvalues very challenging, as they are neither local
>> nor global yet no way exists to explicitly target them in Python 2.x.
>> (If you try to assign to an upvalue, you instead create a new local
>> that shadows it!)
>
> Is this fixed in Python 3.x?
>
> In any case, it is not inherently a problem with local-by-default
> (which I prefer). There could be a way to assign to upvalues. Python
> (at least Python 2.x) just lacks such a mechanism.
>
> -Parke
>
Yes, Python 3.x introduces a "nonlocal" keyword which binds the name
to the nearest upvalue with that name.
/s/ Adam

AltStyle によって変換されたページ (->オリジナル) /