|
Le mer. 28 nov. 2018 à 11:06, Egor Skriptunoff <egor.skriptunoff@gmail.com> a écrit :But the next question from Sony L. would be the following:How to save intermediate value in this codea:b.c()a:b.d()This idea a very strange object type in Lua creating an object that references two:to rewrite it in optimized waylocal x = a:bx.c()x.d()The way I percieve it is that "x" should be a "proxying" function object (which internally will call function "b"), defined in a closure that holds the value "a". Something like:
local x = function(a, b)
local __o___ = a;return function(...)return b(__o__, ...)endendx(c)x(d)