[parenscript-devel] Multiple value calls

Red Daly reddaly at gmail.com
Sun Nov 1 20:15:18 UTC 2009


On Sun, Nov 1, 2009 at 9:34 AM, Vladimir Sedach <vsedach at gmail.com> wrote:

> > Maybe this limitation can be avoided by having an mv-returning function A
> > set a global variable "mvFunctionReturner" equal to the function A and a
> > mv-receiver can check that mvFunctionReturner is set according to the
> > function it called expecting multiple values.  Does this scheme miss any
> > cases?
>
> What about anonymous functions?
>

It would require that an anonymous function being called in Parenscript
source be stored in a variable in the caller.  for example, take the
(implicitly returning) functions below:

(defun foo ()
  (multiple-value-bind (x y)
     (funcall (lambda (z) (values z (+ z 17))) 4)))

=>
function foo () {

var gensymed_lambda = function(z) { mvFunctionReturner = arguments.callee;
mv = [ z+ 17]; return z; }
// bind the results of calling the lambda
var x = gensymed_lambda(4);

var y = null;
if (gensymed_lambda === mvFunctionReturner)
    y = mv[0];

// now implicitly return the same values
mvFunctionReturner = arguments.callee; // arguments.callee === foo unless
foo is renamed
return x;
}

You can deal with anonymous functions basically by naming them, at least in
this scheme.



> I like this idea, and I think it can be made to work. Have you looked
> at whether Linj tries to do multiple return values?


Good idea.  Linj seems to be defunct and inaccessible, unfortunately.


> I suspect someone
> somewhere has thought about and possibly solved this problem before.
>
> Vladimir
>


Thanks,
Red


>
> > Anyway I have thought a little bit about this and I thought I would pass
> it
> > off to the rest of the Parenscripters as a thought experiment.  Assume
> you
> > can do a lot more semantic analysis than Parenscript currently does and
> > transform the compiled source however you want.  But any compiled
> functions
> > must still be able to be treated as normal Javascript functions and all
> and
> > only functions that should return multiple values appear to return them.
> >
> > Cheers,
> > Red
> >
> > _______________________________________________
> > parenscript-devel mailing list
> > parenscript-devel at common-lisp.net
> > http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
> >
> >
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20091101/ecb4d699/attachment.html>


More information about the parenscript-devel mailing list