[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).

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.

On 2010-11-04, at 20:54, Erik Arvidsson wrote:

> We've run into an edge case with the spread operator. What should
> happen if we try to spread null or undefined?
> 
> f(...undefined);
> 
> A. Throw an error
> B. Follow the path of Function.prototype.apply and others and special
> case null and undefined and just call f with 0 arguments
> 
> -- 
> erik
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to