lua-users home
lua-l archive

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



> On Jun 26, 2019, at 1:27 PM, Soni They/Them L. <fakedme@gmail.com> wrote:
> 
> okay so a while back I talked about this "unset foo" idea, that would allow you to get through to shadowed names.
> 
> the example I gave was basically:
> 
> local foo = 1
> do
>   local foo = 2
>   do
>     unset foo
>     foo = 3
>   end
>   assert(foo == 2)
> end
> assert(foo == 3)
> 
> (I don't remember the exact examples I gave but I like this one.)
> 
> anyway, nobody liked it back then and I don't expect anyone to like it now.
> 
> but since we're talking about __close and toclose and stuff, why not use __unset instead? it's called when a variable is unset i.e. goes out of scope. (as long as we don't get the ability to unset variables like I proposed with non-linear lexical scoping, at least.)
> 
> it still doesn't solve the "what to name the <toclose>" problem, but, I'd prefer __unset over __close, personally. (ideally we'd also have a __set for when the value is assigned to one of those special variables, but I digress.)
> 

I’m sure this was asked before. What is the use-case for this? What problem does it solve? My feeling is that any actually need for this is probably an indication of bad software design/coding. In general, you should only be reaching “outwards” into scopes that you understand and control .. and if you understand and control them, then all you need to do it rename the inner locals. And if you dont control them, you are really taking a risk accessing them.

—Tim