On Nov 5, 2010, at 8:32 AM, Dean Landolt wrote:

> Considering the primary use-case for spread is a sugaring for 
> Function.prototype.apply I would expect the same semantics.

"Gimme some sugar, baby!" - Ash Williams

Everyone's into sugar. Good. (Eggs are next. "Eggs have gotten a bad rap, 
Smithers."  - Montgomery Burns)

But really, while spread applied to an array-like (or null or undefined) passed 
as the *only* actual parameter of a call to any callable:

  callable(...arraylike);

could be thought of as desugaring to the original value of 
Function.prototype.apply, now that ES5 has fixed the ES3 botch of translating 
null or undefined thisArg to the global object:

  orig_F_p_apply.call(callable, undefined, arraylike);

in general, spread requires more work. We want to allow

  callable(...head, middle1, middle2, ...tail);

for example, something Function.prototype.apply can't do. And when the callee 
expression is

  foo.bar(some, args, here, ...rest);

the thisArg should be foo.

Also, spread in array initialisers wins:

  const myBigArray = [...yourBigArray, ...plusMore];

Anyway, I agree matching Function.prototype.apply's step 2 special-casing of 
null and undefined, and step 3 exception for other non-object argArray 
parameter types, is best. But spread is not just a sugaring for 
Function.prototype.apply.

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

Reply via email to