Function contexts only exist while they are being evaluated. In this example, you are not evaluating the inner funcs while the outer func is active.
https://github.com/red/red/wiki/Guru-Meditations#function-contexts
but you can't keep it alive, that's not the point of currying and partial application.
but you have to keep variables alive, right? So, for example you have too keep x
till no other inner function use it.
x
is now leaking into global context
/local
part.
set [vars] [values]
, this form stands
func [x y z][loop 5 [print x: x + 1]]
func [y z /local x][set [x][1] loop 5 [print [x: x + 1]]
func [z /local x y][set [x y][1 2] loop 5 [print [x: x + 1]]
func [/local x y z][set [x y z][1 2 3] loop 5 [print [x: x + 1]]
x
value should be preserved somehow, so that those nested functions are able to access it. Same with other arguments.
spec(x0,f(x,y,z))
when called returns spec(y0,f(y,z,x=x0))
, and the new one => f(z,x=x0,y=y0)
do reduce [..]
) to call it