Hi Guys,
(ps (lambda ()(side-effect-call-1)(side-effect-call-2)(side-effect-call-3))) "(function () { sideEffectCall1(); sideEffectCall2(); return sideEffectCall3(); });"
(ps (lambda ()(side-effect-call-1)(side-effect-call-2)(side-effect-call-3)(values))) "(function () { sideEffectCall1(); sideEffectCall2(); sideEffectCall3(); __PS_MV_REG = {}; return null; });"
What I naively expected is this:
"(function () { sideEffectCall1(); sideEffectCall2(); sideEffectCall3(); });"
The value of the last subexpression of the lambda expression gets returned by the return statement, which is in line with the intent of the lisp expression. However, the translated version of functions which exist purely for their side effect look weird. I tried to use (values) as the last subexpression, but then it will explicitly return null and set a PS flag in the translated code. A quick search in the doc or the net didn't reveal a good solution. Isn't it desirable to be able to generate lambda expressions that just don't return anything such that it avoids the clutter of additional lines, or am I missing something obvious? Maybe it's to do with the lisp semantics of returning multiple values (including no values), causing (values) not map well to the intuitive version?
Thank you,
Robert
Hi Robert,
(values) looks weird when you return it, because it gets picked up by the multiple-value return functionality. If you do (ps (lambda ()(side-effect-call-1)(side-effect-call-2)(side-effect-call-3) nil))
the output will look like:
"(function () { sideEffectCall1(); sideEffectCall2(); sideEffectCall3(); return null; });"
There are two things I can see that Parenscript can do to handle situations like yours in a more graceful way:
(return (values)) => return null;
(lambda () (foobar) undefined)) => (function () { foobar; })
If nobody else does this in the meantime, I'll make these optimizations when I get around to working on the backlog of Parenscript tasks I have.
Happy hacking, Vladimir
On Thu, Apr 4, 2013 at 1:00 AM, Robert Monfera monfera.robert@gmail.com wrote:
Hi Guys,
(ps (lambda ()(side-effect-call-1)(side-effect-call-2)(side-effect-call-3))) "(function () { sideEffectCall1(); sideEffectCall2(); return sideEffectCall3(); });"
(ps (lambda ()(side-effect-call-1)(side-effect-call-2)(side-effect-call-3)(values))) "(function () { sideEffectCall1(); sideEffectCall2(); sideEffectCall3(); __PS_MV_REG = {}; return null; });"
What I naively expected is this:
"(function () { sideEffectCall1(); sideEffectCall2(); sideEffectCall3(); });"
The value of the last subexpression of the lambda expression gets returned by the return statement, which is in line with the intent of the lisp expression. However, the translated version of functions which exist purely for their side effect look weird. I tried to use (values) as the last subexpression, but then it will explicitly return null and set a PS flag in the translated code. A quick search in the doc or the net didn't reveal a good solution. Isn't it desirable to be able to generate lambda expressions that just don't return anything such that it avoids the clutter of additional lines, or am I missing something obvious? Maybe it's to do with the lisp semantics of returning multiple values (including no values), causing (values) not map well to the intuitive version?
Thank you,
Robert
parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net