[parenscript-devel] A simpler way to do multiple value return? (Was: PS test failures in 7be9b45)

Vladimir Sedach vsedach at gmail.com
Mon Sep 3 00:28:08 UTC 2012


> We may have crossed a wire here. When you said, "You can do that with
> a global table instead of setting a property on the function object,"
> I thought you had in mind a global table keyed by function *name*,
> which is why I asked about lambdas since they have no names. JS won't
> let you use a function object as a key so one would have to concoct
> some naming scheme.

For my first prototype for the new MV mechanism, that's what I thought
and used gensyms. But then I tried foo[<function object>] and that
works in both FF and CL-JS. But looking at ECMAScript, property
identifiers do indeed have to be JavaScript String objects
(http://ecma-international.org/ecma-262/5.1/#sec-8.10).

> Moreover, if it worked for MV, the sentinel idea could be used to tag
> anything else we wanted into the call. Seems like that could be pretty
> powerful.
>
> Where does this break?

It wouldn't work for calling JavaScript functions that used the
arguments pseudo-array, either for arbitrary arity or for passing
arguments on. There's lots of JS functions around that do things like
foo.apply(null, slice(arguments, x)) or whatever.

> p.s. There's also a way to communicate exactly how many return values
> are desired, short-circuiting any computation that might be needed to
> generate the full VALUES list. (I think this point is independent of
> the above idea but I'll adapt the same examples.) Suppose we have:

In general you have to evaluate all the expressions given to values
for their side-effects, so this would only save a few assignments.

Vladimir




More information about the parenscript-devel mailing list