I started a quick (mainly POC) project simulating lexical scoping for local variables in q functions by automatically adding formal parameters to capture local variables and function projection. For example,
q){a:100; {a+2}}
{a+2}
'a
q))\
q).tele.scope {a:100; {a+2}}
{ a:100; {[x;a] a+2}[;a]}
q)(.tele.scope {a:100; {a+2}})
102
If there is any interest, I’d be on board to put some more work into this, beyond POC-level. Any feedback is similarly appreciated. The code can be found here