lua-users home
lua-l archive

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


Thanks everyone for the suggestions :)

It will take me a while to fully absorb them, I ll get back with any queries after trying them all out.

Abhijit

On Tue, Jul 30, 2019 at 8:18 PM pocomane <pocomane_7a@pocomane.com> wrote:
On Tue, Jul 30, 2019 at 4:37 PM Sergey Kovalev <kovserg33@gmail.com> wrote:
> I try "do <localonly>".It is not similar to noupvalues. It is like
> pure function more.
> I think patch with pure fuction was too vicious in many cases.
> So noupvalues more friendly. It simply hides all upvalues except _ENV.
> But now I cann't say what kind is better.

Yes, it is not fully equivalent, but you can workaround the limitation
with something like:

local env = _ENV -- or local _ENV = _ENV if you prefer
do <localonly>
  env.print"ok"
end

However I think <withupvalue> is closer to what Abhijit was looking
for (if he can live without direct access to globals).