[parenscript-devel] Returning (values)

Robert Monfera monfera.robert at gmail.com
Thu Apr 4 08:00:59 UTC 2013


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




More information about the parenscript-devel mailing list