Tennent's correspondence principle and loop-local variable capture

Vladimir Sedach vsedach at gmail.com
Thu Jun 30 15:33:18 PDT 2011


Hello,

I was recently pointed to the block scoping and TCP discussions by
Peter Michaux, and have a question as to how this will affect the
capture of loop-local variables by closures created in loops.

Some programming languages (Common Lisp in particular) assign a new
binding to loop-local variables on every iteration. JS doesn't do
this, but there is a way to introduce a new lexical environment on
every iteration with the WITH statement, an idea that I first
encountered in the Scheme2JS compiler
(http://www-sop.inria.fr/indes/scheme2js/). Parenscript uses this
trick for translating Common Lisp to JS (a good discussion of how this
shows up in loops is here:
http://lists.common-lisp.net/pipermail/parenscript-devel/2010-December/000914.html).

However the WITH statement is deprecated. How can per-iteration
loop-local variable capture be accomplished with the current proposal,
and what effect does the Block Lambda Revival proposal have on this
issue?

Thank you,
Vladimir


More information about the es-discuss mailing list