You're right, defaults would take care of those few places reducing the
need to reference the arguments object entirely. I think there may be one
or two exceptions, like when there's no default value but an explicit
`undefined` is coerced to undefined but a lack of the argument becomes an
empty
Brandon Benvie wrote:
You're right, defaults would take care of those few places reducing
the need to reference the arguments object entirely. I think there may
be one or two exceptions, like when there's no default value but an
explicit `undefined` is coerced to undefined but a lack of the
Yeah good point, and you don't even need to dump all the named params. In
light of this, I think its feasible to pronounce the arguments object in
ES6 as vestigial and ready for retirement (except for all the legacy code
of course). ES6 claims another victim: [object Arguments].
On Sunday,
On Dec 23, 2012, at 9:38 AM, Brendan Eich wrote:
Brandon Benvie wrote:
You're right, defaults would take care of those few places reducing the need
to reference the arguments object entirely. I think there may be one or two
exceptions, like when there's no default value but an explicit
Arguments object is used here to fill the rest void, but also as an
argument to apply (after converting into a real array) when writing wrapper
functions; eg monkey patches, userspace profiling, etc.
Is there an ES6 way to use apply on rest params? If not, arguments must
live on.
Sent from my
Something like this?
var partial = (fn, ...args) = function(...newArgs){
return fn.apply(this, args.concat(newArgs));
};
On Sun, Dec 23, 2012 at 2:26 PM, Wes Garland w...@page.ca wrote:
Arguments object is used here to fill the rest void, but also as an
argument to apply (after converting
Wes Garland wrote:
Arguments object is used here to fill the rest void, but also as an
argument to apply (after converting into a real array) when writing
wrapper functions; eg monkey patches, userspace profiling, etc.
Is there an ES6 way to use apply on rest params?
A rest parameter is a
As of ES5, apply doesn't require its 2nd arg to be a real array. An arguments
object works fine there.
Brendan Eich bren...@mozilla.com wrote:
Wes Garland wrote:
Arguments object is used here to fill the rest void, but also as an
argument to apply (after converting into a real array) when
Here's one of the examples that was sticking out in my mind earlier that
Brendan's solution takes care of. Array.prototype.reduce requires that if
the initial value isn't provided then the first value of the array is the
initial value.
Using rest:
function reduce(callback, ...initial){
On Sun, Dec 23, 2012 at 1:26 PM, Wes Garland w...@page.ca wrote:
Arguments object is used here to fill the rest void, but also as an
argument to apply (after converting into a real array) when writing wrapper
functions; eg monkey patches, userspace profiling, etc.
Is there an ES6 way to use
Because initialValue can be a provided `undefined` in which case you would
use that, as opposed to a missing value. The specification differentiates
between a provided undefined and a lack of a parameter in a bunch of stdlib
functions/methods.
___
Er missing argument. The spec says If an initialValue was provided in the
call to reduce, The fact that undefined is different from not
provided is the reason you have to hack around with the argument count one
way or another.
On Sun, Dec 23, 2012 at 9:25 PM, Brandon Benvie
On Dec 23, 2012, at 5:35 PM, Brandon Benvie wrote:
Here's one of the examples that was sticking out in my mind earlier that
Brendan's solution takes care of. Array.prototype.reduce requires that if the
initial value isn't provided then the first value of the array is the initial
value.
On Sun, Dec 23, 2012 at 9:25 PM, Brandon Benvie
bran...@brandonbenvie.comwrote:
Because initialValue can be a provided `undefined` in which case you would
use that, as opposed to a missing value. The specification differentiates
between a provided undefined and a lack of a parameter in a bunch
That is an excellent solution!
On Sun, Dec 23, 2012 at 10:46 PM, Axel Rauschmayer a...@rauschma.de wrote:
How about the following solution?
let missingArgument = {}; // or a symbol
function reduce(callback, initial = missingArgument){
let startIndex;
if (initial
Thanks. The first `let` should be a `const`.
On Dec 24, 2012, at 4:47 , Brandon Benvie bran...@brandonbenvie.com wrote:
That is an excellent solution!
On Sun, Dec 23, 2012 at 10:46 PM, Axel Rauschmayer a...@rauschma.de wrote:
How about the following solution?
let missingArgument =
Won't work for an explicitly pass undefined because that triggers assignment of
the default value
Axel Rauschmayer a...@rauschma.de wrote:
How about the following solution?
let missingArgument = {}; // or a symbol
function reduce(callback, initial = missingArgument){
let
Ah yes, so default value can't do the job in any case where undefined is
differentiated from missing, similar to how directly comparing the named
binding to undefined can't differentiate either.
On Sun, Dec 23, 2012 at 11:08 PM, Allen Wirfs-Brock
al...@wirfs-brock.comwrote:
Won't work for an
Ah damn, forgot about that discussion (combinatorial explosion etc.).
On Dec 24, 2012, at 5:08 , Allen Wirfs-Brock al...@wirfs-brock.com wrote:
Won't work for an explicitly pass undefined because that triggers assignment
of the default value
Axel Rauschmayer a...@rauschma.de wrote:
How
Welcome to my life...
Axel Rauschmayer a...@rauschma.de wrote:
Ah damn, forgot about that discussion (combinatorial explosion etc.).
On Dec 24, 2012, at 5:08 , Allen Wirfs-Brock al...@wirfs-brock.com wrote:
Won't work for an explicitly pass undefined because that triggers assignment
of the
On Sun, Dec 23, 2012 at 10:46 PM, Axel Rauschmayer a...@rauschma.de wrote:
How about the following solution?
let missingArgument = {}; // or a symbol
function reduce(callback, initial = missingArgument){
let startIndex;
An explicit undefined will trigger the default value,
I never fully understood why the arguments object couldn't be an array, and I
know there is at least an attempted purge of the arguments object from the
language with the addition of rest parameters.. But, for the transitional
period, can the arguments object have an @@iterator property
.. But, for the
transitional period, can the arguments object have an @@iterator property?
Please??
Yes
(I looked for it in the draft and didn't see it, but I might not have
known where to look.)
Likely because Allen had enough on his plate for this draft, but there is
already a ticket based on a resolution
the language with the addition of rest parameters.. But, for the
transitional period, can the arguments object have an @@iterator
property? Please??
Yes
(I looked for it in the draft and didn't see it, but I might not have
known where to look.)
Likely because Allen had enough
It's good this will be added (no reason not to) but I'll note that is much
less of a requirement to even use the arguments object at all, especially
iteration use cases that are pretty much filled by rest. In fact (almost?)
the only place I've actually referenced the arguments object is to count
Parameter default values weren't good enough for this?
[[[Sent from a mobile device. Please forgive brevity and typos.]]]
Dr. Axel Rauschmayer
a...@rauschma.de
Home: http://rauschma.de
Blog: http://2ality.com
On 22.12.2012, at 23:57, Brandon Benvie bran...@brandonbenvie.com wrote:
It's good
26 matches
Mail list logo