Hi Parenscripters,
As far as I can tell, multiple-value function calls are a unique feature of lisp. I would like the ability to perform multiple-value calls in Parenscript but I don't know if a sane solution exists or not.
Can anyone come up with a scheme for returning multiple values that translates well to Javascript? Ideally such a scheme would not introduce much overhead for usual functions that do not use or return multiple values (though perhaps setting some sort of global MV flag might be inexpensive enough). Functions that return multiple values should also only appear to return a single value when called by a function that expects only one return value (including native javascript functions).
(defun paren-mv-returner ()
(return (values 1 2 3)))
=>
function parenMvReturner() {
/* do some magic with the values 2 and 3 */
return 1;
}
// one implementation might be
var mv = undefined;
function parenMvReturner() {
mv = [2, 3];
return 1;
}
// this scheme needs to adjust the return statement of every function so it might not be sufficient
// consider this other function
function parenMySingleReturner () {
var x = parenMvReturner();