Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-23 Thread Brendan Eich
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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,

Re: @@iterator in arguments object

2012-12-23 Thread Allen Wirfs-Brock
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

Re: @@iterator in arguments object

2012-12-23 Thread Wes Garland
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-23 Thread Brendan Eich
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

Re: @@iterator in arguments object

2012-12-23 Thread Allen Wirfs-Brock
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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){

Re: @@iterator in arguments object

2012-12-23 Thread Jason Orendorff
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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. ___

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-23 Thread Allen Wirfs-Brock
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.

Re: @@iterator in arguments object

2012-12-23 Thread Rick Waldron
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-23 Thread Axel Rauschmayer
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 =

Re: @@iterator in arguments object

2012-12-23 Thread Allen Wirfs-Brock
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

Re: @@iterator in arguments object

2012-12-23 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-23 Thread Axel Rauschmayer
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

Re: @@iterator in arguments object

2012-12-23 Thread Allen Wirfs-Brock
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

Re: @@iterator in arguments object

2012-12-23 Thread Rick Waldron
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,

@@iterator in arguments object

2012-12-22 Thread Nathan Wall
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

Re: @@iterator in arguments object

2012-12-22 Thread Rick Waldron
.. 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

RE: @@iterator in arguments object

2012-12-22 Thread Nathan Wall
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

Re: @@iterator in arguments object

2012-12-22 Thread Brandon Benvie
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

Re: @@iterator in arguments object

2012-12-22 Thread Axel Rauschmayer
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