lua-users home
lua-l archive

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


Yes indeed. There is no pure function in lua. That's why they are quite rate.
upvalues are almost everywhere that's we are unable to isolate
different part of code.
You have to declare all used variables as local to ensure there is no
side effect, but if you forget to declare some variable
the behaviour will depends on context. Even if we override _ENV
variable to disable access to globals, but we can't disable upvalues.
The only solution is to use "load" function
https://pastebin.com/9jrvzR33 but it isn't perfect.

чт, 4 июл. 2019 г. в 08:01, Egor Skriptunoff <egor.skriptunoff@gmail.com>:
>
> On Thu, Jul 4, 2019 at 12:47 AM Sergey Kovalev wrote:
>>
>>
>> If we would have pure function declaration this problem causes less pain.
>> Pure function like ordinary function but isolated from global and
>> up-values.
>
>
> Pure functions are quite rare.
> Upvalues are almost everywhere in Lua :-)
>