<div>PS seems to think that the variable named BLOCK is being captured by</div><div>the irrelevant lambda and inserts a WITH binding.</div><div><br></div><div> PS> (ps (loop :for i :from 0 :below 5 :do </div><div> (let ((block (elt blocks i))) </div>
<div> (foo block)</div><div> (lambda () nil))))</div><div><br></div><div> "for (var i = 0; i < 5; i += 1) {</div><div> with ({ block : null }) {</div><div> var block = blocks[i];</div>
<div> foo(block);</div><div> function () {</div><div> return null;</div><div> };</div><div> };</div><div> };"</div><div><br></div><div>This doesn't happen if you take out the lambda:</div>
<div><br></div><div> PS> (ps (loop :for i :from 0 :below 5 :do</div><div> (let ((block (elt blocks i)))</div><div> (foo block))))</div><div><br></div><div> "for (var i = 0; i < 5; i += 1) {</div>
<div> var block = blocks[i];</div><div> foo(block);</div><div> };"</div><div><br></div><div>... or even if you rename BLOCK to B:</div><div><br></div><div> PS> (ps (loop :for i :from 0 :below 5 :do </div>
<div> (let ((b (elt blocks i))) </div><div> (foo b)</div><div> (lambda () nil))))</div><div> </div><div> "for (var i = 0; i < 5; i += 1) {</div><div> var b = blocks[i];</div>
<div> foo(b);</div><div> function () {</div><div> return null;</div><div> };</div><div> };"</div><div><br></div><div><div>I thought this might be because PS had compiled a different form where</div>
<div>BLOCK was indeed captured by closure in a loop and was remembering</div><div>this inappropriately. But that doesn't seem right because the problem</div><div>is reproducible on a fresh restart of PS.</div></div><div>
<br></div><div>Daniel</div>