On 2008-09-10, at 03:49EDT, Brendan Eich wrote:
> Constructors can't be .apply'ed when invoked
> via operator new -- a bug that the proposed and so-far warmly-
> received spread operator solves nicely:
>
> new callable(...argsarray)
>
> Note no explicit |this| parameter for constructors, so spread does
> not solve the Function.prototype.apply problem for plain calls:
>
> Safe.universalApply(callable, thisobj, argsarray)
>
> can't be rewritten as:
>
> callable(this=thisobj, ...argsarray)
>
> as Tucker suggested recently (he used receiver=, but I still think
> this assignment is better, since it's illegal currently and it avoids
> adding a new contexually reserved word -- detail!).
It's great when you read more into my comments than I intended :)
I was proposing being able to rename `this` in the body of a method by
naming it in the formals (parameter) list. My purpose was to make it
easier to understand when `this` is being closed over in an internal
function. You are proposing being able to assign to it in the actuals
(arguments) list. A nice parallelism.
> Still, if we had spread, would we be bothering with Function.apply,
> or with those pesky strict mode arguments tweaks? Food for thought.
> Sometimes adding new syntax avoids silly name mangling and
> unnecessary modalities.
Perhaps?
Function.prototype.bind = function(this=thisFunc,
context, ...partial) {
return function(...rest) {
return thisFunc(this=context, ...partial, ...rest);
}
}
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss