Specifically, I'm having a hard time seeing how this:<div><br></div><div><div> function blah(obj) {</div><div> for (var key in obj) {</div><div> with ({ x : null }) {</div><div> var x = [];</div>
<div> // do anything at all here...</div><div><br></div><div>can ever be better than this:</div><div><br></div><div><div> function blah(obj) {</div><div> for (var key in obj) { </div><div> var x = [];</div>
<div> // do that thing here instead...</div></div><div><br></div><div>What am I missing?</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">2011/1/28 Daniel Gackle <span dir="ltr"><<a href="mailto:danielgackle@gmail.com">danielgackle@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I'm running to this WITH clause in a number of places, but can't see<div>the (potential) bug you describe in any of them. Can you provide an</div>
<div>example of this bug (that necessitates the WITH)? I don't get it yet.</div>
<div><br></div><div>Daniel</div><div><br><div><div><div><div><br><div class="gmail_quote">2010/12/10 Vladimir Sedach <span dir="ltr"><<a href="mailto:vsedach@gmail.com" target="_blank">vsedach@gmail.com</a>></span><div>
<div></div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The WITH clause is there to make sure that lambdas capture a fresh<br>
binding of loop-local variables per iteration (otherwise they'd all<br>
share the same binding which would get incremented on every loop<br>
iteration).<br>
<br>
I'm guessing the reason your code doesn't run across this bug is that<br>
the lambda that captures time gets called once per iteration and<br>
discarded.<br>
<br>
Vladimir<br>
<br>
2010/12/7 Daniel Gackle <<a href="mailto:danielgackle@gmail.com" target="_blank">danielgackle@gmail.com</a>>:<br>
<div><div></div><div>> Here's a really strange one.<br>
> We have a form like the following. I've stripped it down for brevity, so it<br>
> looks weird:<br>
> (loop :for time :from time1 :below time2 :do<br>
> (when (foo<br>
> (ë ()<br>
> (bar<br>
> (ë () (blah)) time))<br>
> time)<br>
> (break)))<br>
> It used to generate this:<br>
> for (var time = time1; time < time2; time += 1) {<br>
> if (foo(function () {<br>
> return barr(function () {<br>
> return blah();<br>
> }, time);<br>
> }, time)) {<br>
> break;<br>
> };<br>
> };<br>
> But now it generates this:<br>
> for (var time = time1; time < time2; time += 1) {<br>
> with ({ time : time }) {<br>
> if (foo(function () {<br>
> return bar(function () {<br>
> return blah();<br>
> }, time);<br>
> }, time)) {<br>
> break;<br>
> };<br>
> };<br>
> };<br>
> That is one weird WITH clause in there! No doubt it has something<br>
> to do with lexical scoping magic going on under the hood. But<br>
> I definitely don't want it in a performance-critical loop.<br>
> Daniel<br>
</div></div>> _______________________________________________<br>
> parenscript-devel mailing list<br>
> <a href="mailto:parenscript-devel@common-lisp.net" target="_blank">parenscript-devel@common-lisp.net</a><br>
> <a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
><br>
><br>
<br>
_______________________________________________<br>
parenscript-devel mailing list<br>
<a href="mailto:parenscript-devel@common-lisp.net" target="_blank">parenscript-devel@common-lisp.net</a><br>
<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
</blockquote></div></div></div><br></div></div></div></div></div>
</blockquote></div><br></div></div>