Re: Clarification on function default param values

2013-10-01 Thread Mark Miller
On Tue, Oct 1, 2013 at 3:16 PM, Claus Reinke wrote: > Generally variables are brought into scope by an explicitly appearing >> defining occurrence. Two exceptions are the "function" brings into scope >> both "this" and "arguments". These remain in scope until shadowed by a >> nested "function" or

Re: Clarification on function default param values

2013-10-01 Thread Andrea Giammarchi
oops, it wasn't intentional. I should have checked ... opened a new one. br On Tue, Oct 1, 2013 at 3:39 PM, Brendan Eich wrote: > Thread-hijacking is poor form. > > /be > ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/lis

Re: Clarification on function default param values

2013-10-01 Thread Brendan Eich
Thread-hijacking is poor form. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Clarification on function default param values

2013-10-01 Thread Claus Reinke
Generally variables are brought into scope by an explicitly appearing defining occurrence. Two exceptions are the "function" brings into scope both "this" and "arguments". These remain in scope until shadowed by a nested "function" or by an explicit definition. Note that "this" can never be explic

Re: Clarification on function default param values

2013-10-01 Thread Dmitry Soshnikov
On Mon, Sep 30, 2013 at 8:21 PM, Brandon Benvie wrote: > On 9/30/2013 3:51 PM, Dmitry Soshnikov wrote: > >> Just re-read meeting notes, OK, cool on two scopes (seems like they are >> not in the spec yet). Want to double-check though: whether it will be >> possible to transpile now to ES3? From wh

Re: Clarification on function default param values

2013-10-01 Thread Andrea Giammarchi
I need to read everything Brendan suggested but if anyone would be so kind to refresh my memories on this arrow function I'd appreciate that. I don't need much more than yes/no as answer, thanks. 1. `var o = {method: () => this};` will o.method() return o ? (I guess nope) Considering the follow

Re: Clarification on function default param values

2013-10-01 Thread Mark S. Miller
I agree that the discussions as I remember them do not go into this level of detail. Thanks for being so explicit about precise choices. However, I do recall that the consensus we had was enough to rule out #3, or indeed any solution where arrow functions have their own arguments object. And even

Re: Clarification on function default param values

2013-10-01 Thread Brendan Eich
Andrea Giammarchi wrote: Does `null` count as undefined too No. See the draft spec and many threads and meeting notes. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Clarification on function default param values

2013-10-01 Thread Erik Arvidsson
3 and 7 both seems good. Personally I prefer #7 but I'm worried that it might be too surprising that arguments refers to the outer function. On Tue, Oct 1, 2013 at 11:11 AM, Allen Wirfs-Brock wrote: > > On Oct 1, 2013, at 12:03 AM, André Bargull wrote: > >> Brandon Benvie

Re: Clarification on function default param values

2013-10-01 Thread Andrea Giammarchi
I see. Does `null` count as undefined too or it must be explicitly undefined ? not that using a transpiler this matters much ... just curious about how the ES < 6 will look like. On Tue, Oct 1, 2013 at 11:02 AM, Brendan Eich wrote: > No, we are using undefined actual parameter value, not argume

Re: Clarification on function default param values

2013-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2013, at 12:03 AM, André Bargull wrote: >> > Brandon Benvie >> > September 30, 2013 8:48 PM >> > I'm actually now really curious what the following does: >> > >> > ``` >> > function foo(x, y = (() => { arguments[0] = "foo"; return "bar" })()) { >> > ret

Re: Clarification on function default param values

2013-10-01 Thread Brendan Eich
No, we are using undefined actual parameter value, not argument.length, to trigger defaulting -- as discussed many times and cited by me (again) recently in reply to Oliver. Please do not go backward. /be ___ es-discuss mailing list es-discuss@mozill

Re: Clarification on function default param values

2013-10-01 Thread Andrea Giammarchi
Just a quick one. I think the best representation in ES3 or 5 would be the following ```javascript function foo(x, y, z) { switch(arguments.length) { case 0: x = 1; case 1: y = 2; case 2: z = 3; } // whatever logic involved, i.e. return x + y + z; } ``` no break and no default

Re: Clarification on function default param values

2013-10-01 Thread Andreas Rossberg
On 30 September 2013 22:17, Jeff Morrison wrote: > So I think during the last meeting it was decided that we'd now have two > scopes for functions with default param values: One for head/params, and one > for the function body. > Was it also agreed that we'd use let-binding (vs var-binding) for th

Re: Clarification on function default param values

2013-10-01 Thread André Bargull
>/ Brandon Benvie > />/ September 30, 2013 8:48 PM />/ I'm actually now really curious what the following does: />/ />/ ``` />/ function foo(x, y = (() => { arguments[0] = "foo"; return "bar" })()) { />/return

Re: Clarification on function default param values

2013-09-30 Thread Brandon Benvie
On 9/30/2013 8:57 PM, Brendan Eich wrote: Easy: arguments is an early error in the body of an arrow. Ok cool, that simplifies my previous examples a bit then. Instead of using `call` and specifying the name of each argument, you can just use `.apply(this, arguments)`. ___

Re: Clarification on function default param values

2013-09-30 Thread Brendan Eich
Brandon Benvie September 30, 2013 8:48 PM I'm actually now really curious what the following does: ``` function foo(x, y = (() => { arguments[0] = "foo"; return "bar" })()) { return [x, y]; } Easy: arguments is an early error in the body of an arrow. http://wiki.

Re: Clarification on function default param values

2013-09-30 Thread Brandon Benvie
I'm actually now really curious what the following does: ``` function foo(x, y = (() => { arguments[0] = "foo"; return "bar" })()) { return [x, y]; } foo(5); ``` Arrow functions are not implicitly strict currently, right? If so, the above should return `["foo", "bar"]`.

Re: Clarification on function default param values

2013-09-30 Thread Brandon Benvie
On 9/30/2013 3:51 PM, Dmitry Soshnikov wrote: Just re-read meeting notes, OK, cool on two scopes (seems like they are not in the spec yet). Want to double-check though: whether it will be possible to transpile now to ES3? From what I've seen in the notes, the head-scope will be able to access `

Re: Clarification on function default param values

2013-09-30 Thread Brandon Benvie
On 9/30/2013 7:34 PM, Matthew Robb wrote: var f = function(a=this){} would transpile to something like: var f = (function(){ function __funcHead__(){ a=this; } function __funcBody__(){ // do stuff } var a; return function(a){__funcHead__.apply(this, arguments);return __funcBody__.call(this)

Re: Clarification on function default param values

2013-09-30 Thread Matthew Robb
var f = function(a=this){} would transpile to something like: var f = (function(){ function __funcHead__(){ a=this; } function __funcBody__(){ // do stuff } var a; return function(a){__funcHead__.apply(this, arguments);return __funcBody__.call(this)} }()); If my interpretation is correct.

Re: Clarification on function default param values

2013-09-30 Thread Dmitry Soshnikov
On Mon, Sep 30, 2013 at 1:17 PM, Jeff Morrison wrote: > So I think during the last meeting it was decided that we'd now have two > scopes for functions with default param values: One for head/params, and > one for the function body. > Just re-read meeting notes, OK, cool on two scopes (seems lik

Re: Clarification on function default param values

2013-09-30 Thread Jeff Morrison
Typo in first scenario fixed On 9/30/13 1:17 PM, Jeff Morrison wrote: So I think during the last meeting it was decided that we'd now have two scopes for functions with default param values: One for head/params, and one for the function body. Was it also agreed that we'd use let-binding (vs var

Clarification on function default param values

2013-09-30 Thread Jeff Morrison
So I think during the last meeting it was decided that we'd now have two scopes for functions with default param values: One for head/params, and one for the function body. Was it also agreed that we'd use let-binding (vs var-binding) for the default-value expressions? I also just wanted to cl