On Fri, Nov 5, 2010 at 8:14 AM, P T Withington <[email protected]> wrote:
> [2p. from the Lisp world, the putative inventor of the rest/spread
> operator.]
>
> In Lisp, arglists are lists instead of arrays, the operator is `.`, and
> conveniently, the empty list, `()`, and Lisp null, `NIL`, are just two ways
> to write the same atom. In Lisp, option B just falls out:
>
> (f . NIL) === (f . ()) === (f)
>
> +1 for B as the best approximation (in the absence of a List data type).
>
If the closest analogue of a Lispy list is an ESy array, then I think the
empty array would be the best approximation.
>
> We can't really have the symmetry that Zeppieri is looking for because you
> want the rest operator to return an empty array when there are no rest args
> (rather than null), so you don't need to test for null before manipulating a
> rest arg.
>
>
I can (finally) articulate my initial intuition (in favor of Erik's plan A).
To the extent that the spread operator and rest args should be symmetrical,
the following function should be an identity over its domain:
function id(x) {
return (function(...x) { return x; })(...x);
}
But it can only be an identity when its argument is an array.
Whether or not anyone else cares about this symmetry is another matter.
Second issue: Erik suggests (plan B) that null and undefined are
specifically special cased. I can't tell whether Brendan agrees with that or
wants spread to be legal on any input whatsoever, because he writes that
spread "should return an empty array on mismatch."
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss