Iterating default function arguments

2015-03-25 Thread Robin Cafolla
Hi there, I was wondering if there were any plans to modify `arguments` to include default parameters (e.g. changing it from a simpleParameterList) or to include a new property that does allow iteration of all values available to a function. for example: function foo( a, b = 2 ) {

Re: Iterating default function arguments

2015-03-25 Thread Rick Waldron
On Wed, Mar 25, 2015 at 2:40 AM Robin Cafolla ro...@zombiemongoose.com wrote: Hi there, I was wondering if there were any plans to modify `arguments` to include default parameters (e.g. changing it from a simpleParameterList) or to include a new property that does allow iteration of all

Re: Iterating default function arguments

2015-03-25 Thread Andrea Giammarchi
I think the main concern was: Currently I can't see a way of getting default parameters as an iterable object. and indeed `arguments` is not the magic variable you are looking for. However, you are inside your own defined function so either you don't specify defaults, or you iterate over `[a,

Re: Iterating default function arguments

2015-03-25 Thread Axel Rauschmayer
I'm all for using Reflect, but looking at the API as listed on MDN, the harmony-reflect github, or the spec, i don't see an obvious way of getting the parameters. If I understand you correctly (and this is not about parsing the parameter definitions) then how about the following solution?

Re: Iterating default function arguments

2015-03-25 Thread Robin Cafolla
Well my use case is for something I can insert into an existing function, in fact, a lot of functions, hopefully without manually listing the arguments. ```js function bar( parameters ) { for ( var i = 0; i parameters.length; i++ ) { // do something interesting with each parameter of

Re: Iterating default function arguments

2015-03-25 Thread Brendan Eich
Andrea Giammarchi wrote: I think the answer is still a static `[a, b]` as list of arguments to apply, but I can see some lack of reflection capability ... or maybe Reflect would solve this? Yes, Reflect -- we want a mirror approach, not more magic object like arguments or function. /be

Re: Iterating default function arguments

2015-03-25 Thread Andrea Giammarchi
Sounds good to me and makes perfect sense. Robin? On Wed, Mar 25, 2015 at 5:23 PM, Brendan Eich bren...@mozilla.org wrote: Andrea Giammarchi wrote: I think the answer is still a static `[a, b]` as list of arguments to apply, but I can see some lack of reflection capability ... or maybe

Re: Iterating default function arguments

2015-03-25 Thread Robin Cafolla
Oops. Sorry about that. On 25 March 2015 at 19:01, Andrea Giammarchi andrea.giammar...@gmail.com wrote: you keep replying to me only ... you really need to reply-all since I've actually no idea ;-) On Wed, Mar 25, 2015 at 5:53 PM, Robin Cafolla ro...@zombiemongoose.com wrote: I'm all for