3 ms·
This is indeed an ancient problem. I loved the 1992 Lisp FAQ comment by jjwiseman. :-) Nim handles this with `closureScope` and `capture` ( https://nim-lang.o
by cb321 3y ago
This is indeed an ancient problem. I loved the 1992 Lisp FAQ comment by jjwiseman. :-)
Nim handles this with `closureScope` and `capture` ( https://nim-lang.org/docs/system.html#closureScope.t,untyped https://nim-lang.org/docs/system.html#closureScope.t,untyped ).
It's debatable if anything non-automatic counts as a "fix".
Nim has for-loop macros that should make it possible to instead say `for i in captured(0..5): ...` or maybe `for closed(i) in 0..5: ...`. That might be a bit nicer, but would still be non-automatic. So, unnecessary qualifications can exist / persist.
Speaking of persistence, sometimes loop bodies evolve and the x:=x magic used to be needed but is no longer. Version control history might help decide if the extra step was unnecessary or vestigial, though it would surely slow things down (and perhaps run into intermediate uncompilable states of the code). No idea if David Chase and rsc looked at that aspect in their analysis.