specialize: function [fun [function!] defs [block!]][ spec: copy/deep spec-of :fun body: copy/deep body-of :fun foreach [arg value] defs [ arg: to word! form arg pos: find spec arg remove/part pos pick [2 1] block? pos/2 parse body rule: [some [change only arg value | into rule | skip]] ] func spec body ]
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.
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.
xis now leaking into global context
set [vars] [values], this form stands
func [x y z][loop 5 [print x: x + 1]]
func [y z /local x][set [x] 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]]
xvalue should be preserved somehow, so that those nested functions are able to access it. Same with other arguments.