[parenscript-devel] Lexical scoping with LAMBDA
It appears as though there might be a gap in the lexical scoping implementation in the compiler: (ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };" vs. (ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x))) "var x = 10; var x33 = 1; foo(x33); ++x;" Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts. Scott
Bugs are a major theme on this list. As far as I know, Parenscript lacks unit tests that run the compiled Javascript code. Is that still correct? Perhaps it is time to introduce this feature? There are a few options here: - cl-javascript is a pure lisp implementation of ECMAScript, and it actually works for most normal language cases - cl-spidermonkey uses the FFI to interact with Mozilla's JS engine - v8, either through the FFI or a simple command line This should allow the project to test much more rigorously than the current kinda kludgy test framework. As a reference, I currently do this in PSOS: https://github.com/gonzojive/paren-psos/blob/master/test/test-package.lisp - Red On Tue, Sep 6, 2011 at 11:48 PM, <sblist@me.com> wrote:
It appears as though there might be a gap in the lexical scoping implementation in the compiler:
(ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };"
vs.
(ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x)))
"var x = 10; var x33 = 1; foo(x33); ++x;"
Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts.
Scott
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
That's a good point. Also, this would be a major, if auxiliary, advantage of a self-hosted PS. Daniel On Tue, Sep 6, 2011 at 5:45 PM, Red Daly <reddaly@gmail.com> wrote:
Bugs are a major theme on this list. As far as I know, Parenscript lacks unit tests that run the compiled Javascript code. Is that still correct? Perhaps it is time to introduce this feature? There are a few options here:
- cl-javascript is a pure lisp implementation of ECMAScript, and it actually works for most normal language cases - cl-spidermonkey uses the FFI to interact with Mozilla's JS engine - v8, either through the FFI or a simple command line
This should allow the project to test much more rigorously than the current kinda kludgy test framework.
As a reference, I currently do this in PSOS: https://github.com/gonzojive/paren-psos/blob/master/test/test-package.lisp
- Red
On Tue, Sep 6, 2011 at 11:48 PM, <sblist@me.com> wrote:
It appears as though there might be a gap in the lexical scoping implementation in the compiler:
(ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };"
vs.
(ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x)))
"var x = 10; var x33 = 1; foo(x33); ++x;"
Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts.
Scott
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Actually, I added runnable tests (via cl-javascript) earlier this year. There's just not very many test cases. The test cases themselves are in t/eval-tests.lisp Vladimir On Tue, Sep 6, 2011 at 7:45 PM, Red Daly <reddaly@gmail.com> wrote:
Bugs are a major theme on this list. As far as I know, Parenscript lacks unit tests that run the compiled Javascript code. Is that still correct? Perhaps it is time to introduce this feature? There are a few options here: - cl-javascript is a pure lisp implementation of ECMAScript, and it actually works for most normal language cases - cl-spidermonkey uses the FFI to interact with Mozilla's JS engine - v8, either through the FFI or a simple command line This should allow the project to test much more rigorously than the current kinda kludgy test framework. As a reference, I currently do this in PSOS: https://github.com/gonzojive/paren-psos/blob/master/test/test-package.lisp - Red On Tue, Sep 6, 2011 at 11:48 PM, <sblist@me.com> wrote:
It appears as though there might be a gap in the lexical scoping implementation in the compiler:
(ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };"
vs.
(ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x)))
"var x = 10; var x33 = 1; foo(x33); ++x;"
Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts.
Scott
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Super, thanks! Maybe we should suggest including tests with bug fixes/ reports. Red On Sep 8, 2011, at 9:06 PM, Vladimir Sedach <vsedach@gmail.com> wrote:
Actually, I added runnable tests (via cl-javascript) earlier this year. There's just not very many test cases.
The test cases themselves are in t/eval-tests.lisp
Vladimir
On Tue, Sep 6, 2011 at 7:45 PM, Red Daly <reddaly@gmail.com> wrote:
Bugs are a major theme on this list. As far as I know, Parenscript lacks unit tests that run the compiled Javascript code. Is that still correct? Perhaps it is time to introduce this feature? There are a few options here: - cl-javascript is a pure lisp implementation of ECMAScript, and it actually works for most normal language cases - cl-spidermonkey uses the FFI to interact with Mozilla's JS engine - v8, either through the FFI or a simple command line This should allow the project to test much more rigorously than the current kinda kludgy test framework. As a reference, I currently do this in PSOS: https://github.com/gonzojive/paren-psos/blob/master/test/test-package.lisp - Red On Tue, Sep 6, 2011 at 11:48 PM, <sblist@me.com> wrote:
It appears as though there might be a gap in the lexical scoping implementation in the compiler:
(ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };"
vs.
(ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x)))
"var x = 10; var x33 = 1; foo(x33); ++x;"
Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts.
Scott
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Just pushed a fix for this bug. Thanks for the bug report! Vladimir On Tue, Sep 6, 2011 at 5:48 PM, <sblist@me.com> wrote:
It appears as though there might be a gap in the lexical scoping implementation in the compiler:
(ps (lambda (x) (let ((x 1)) (foo x)) (incf x))) => "function (x) { var x = 1; foo(x); return ++x; };"
vs.
(ps (let ((x 10)) (let ((x 1)) (foo x)) (incf x)))
"var x = 10; var x33 = 1; foo(x33); ++x;"
Although function parameters have their own lexical bindings, the environment still needs to be informed of those bindings so that LET forms in the function body can rename any conflicts.
Scott
_______________________________________________ parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
participants (4)
-
Daniel Gackle
-
Red Daly
-
sblist@me.com
-
Vladimir Sedach