[parenscript-devel] Inaccurate lexical capture in loop

Vladimir Sedach vsedach at gmail.com
Tue May 8 17:08:06 UTC 2012


This was a bug in the PS-JS intermediate representation package, which
was using CL package symbols. I've pushed a fix. Thanks for the bug
report!

Vladimir

On Wed, Apr 11, 2012 at 3:03 PM, Daniel Gackle <danielgackle at gmail.com> wrote:
> PS seems to think that the variable named BLOCK is being captured by
> the irrelevant lambda and inserts a WITH binding.
>
>    PS> (ps (loop :for i :from 0 :below 5 :do
>              (let ((block (elt blocks i)))
>                (foo block)
>                (lambda () nil))))
>
>    "for (var i = 0; i < 5; i += 1) {
>        with ({ block : null }) {
>            var block = blocks[i];
>            foo(block);
>            function () {
>                return null;
>            };
>        };
>    };"
>
> This doesn't happen if you take out the lambda:
>
>    PS> (ps (loop :for i :from 0 :below 5 :do
>              (let ((block (elt blocks i)))
>                (foo block))))
>
>    "for (var i = 0; i < 5; i += 1) {
>        var block = blocks[i];
>        foo(block);
>    };"
>
> ... or even if you rename BLOCK to B:
>
>    PS> (ps (loop :for i :from 0 :below 5 :do
>              (let ((b (elt blocks i)))
>                (foo b)
>                (lambda () nil))))
>
>    "for (var i = 0; i < 5; i += 1) {
>        var b = blocks[i];
>        foo(b);
>        function () {
>            return null;
>        };
>    };"
>
> I thought this might be because PS had compiled a different form where
> BLOCK was indeed captured by closure in a loop and was remembering
> this inappropriately. But that doesn't seem right because the problem
> is reproducible on a fresh restart of PS.
>
> Daniel
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>




More information about the parenscript-devel mailing list