[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lambdas
- From: Philippe Verdy <verdy_p@...>
- Date: Sun, 18 Nov 2018 21:02:00 +0100
As well the given examples are not pure lambda:
\x,y,z(x+(x-2)*g(x,y,z-2*(x+y))-y*z)
or its transformation into
function(x,y,z) return x+(x-2)*g(x,y,z-2*(x+y))-y*z end
is bound in a closure referencing "g", which is not an upvalue (an input parameter) of that function. May be it can be viewed as an output parameter but then it sould be still written as:
\x,y,z,g(x+(x-2)*g(x,y,z-2*(x+y))-y*z)
or
function(x,y,z,g) return x+(x-2)*g(x,y,z-2*(x+y))-y*z end
Closures are exactly that: they are passing additional parameters not passed explicitly by the call stack, to create a complete environment (context) where a lambda can be evaluated because all input and output variables are bound (independantly of additional local varaibles that may be defined inside the function.