Re: bind operator (was: arrow function syntax simplified)

2012-03-29 Thread David Herman
On Mar 28, 2012, at 2:19 PM, Erik Arvidsson wrote: With your proposal I have to do let f = obj.foo; obj::f which is even longer than the original. That's not a fair argument. There's no need for the let-binding; you can write obj::obj.foo or ::obj.foo Now, you might feel that it's

bind operator (was: arrow function syntax simplified)

2012-03-28 Thread David Herman
On Mar 27, 2012, at 9:14 PM, Russell Leggett wrote: I'm sure this is a bit of a tangent, but the other major related case is passing a method as an argument but needing to retain the correct this. Obviously, that is what bind was meant for, but that is inconvenient when passing methods for

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Russell Leggett
On Wed, Mar 28, 2012 at 1:37 PM, David Herman dher...@mozilla.com wrote: On Mar 27, 2012, at 9:14 PM, Russell Leggett wrote: I'm sure this is a bit of a tangent, but the other major related case is passing a method as an argument but needing to retain the correct this. Obviously, that is

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread John Tamplin
On Wed, Mar 28, 2012 at 2:02 PM, Russell Leggett russell.legg...@gmail.comwrote: Ah, there you go. I figured I wasn't the first to think of it. I think it might be worth talking about this in relation to the shorthand function syntax, because it could pull the lexical this issue out of that

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Kevin Smith
I'm not sure how to quantify this, but I believe that if such a bind operator were available, it would be overwhelmingly be used to simulate lexical |this|. If syntax is about optimizing the common case, then shouldn't we just provide a function form which lexically binds |this|? kevin

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Russell Leggett
On Wed, Mar 28, 2012 at 2:38 PM, John Tamplin j...@google.com wrote: On Wed, Mar 28, 2012 at 2:02 PM, Russell Leggett russell.legg...@gmail.com wrote: Ah, there you go. I figured I wasn't the first to think of it. I think it might be worth talking about this in relation to the shorthand

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Russell Leggett
On Wed, Mar 28, 2012 at 3:17 PM, Kevin Smith khs4...@gmail.com wrote: I'm not sure how to quantify this, but I believe that if such a bind operator were available, it would be overwhelmingly be used to simulate lexical |this|. If syntax is about optimizing the common case, then shouldn't we

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Kevin Smith
Thats not the only common case. It might be *the most* common, but I see a lot method pointers that need binding too. Can you post an example? kevin ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Kevin Smith
Russell, I looked at the other thread more carefully and now understand what you're saying. Can't we use a bound |this| function for all these cases? needsCallback(x = foo.bar(x)); needsCallback(x = this.bar(x)); // Suppose for a moment that - also binds |this| needsCallback((x,

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Nadav Shesek
On Wed, Mar 28, 2012 at 9:57 PM, Kevin Smith khs4...@gmail.com wrote: It seems that with bound |this| functions, the need to explicitly bind |this| tends to fall away. This is true for function literals that needs to be bound to the `this` context in the scope where they're created, but not

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Nadav Shesek
BTW, there's also some discussion on a bind operator at a ticket I opened on CoffeeScript's tracker, https://github.com/jashkenas/coffee-script/issues/2136 (slightly based on the syntax proposed on Sugar for *.prototype and for calling methods as functions

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Russell Leggett
On Wed, Mar 28, 2012 at 3:57 PM, Kevin Smith khs4...@gmail.com wrote: Russell, I looked at the other thread more carefully and now understand what you're saying. Can't we use a bound |this| function for all these cases? needsCallback(x = foo.bar(x)); needsCallback(x = this.bar(x));

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Erik Arvidsson
I find this proposal backwards. It requires an expeession as the right hand side. Alex proposed something similar a long time ago. He suggested using '!' instead of '.'. This is important because the common use case we want to solve is to make 'obj.foo.bind(foo)' be written as 'obj!foo'. With your

Re: bind operator (was: arrow function syntax simplified)

2012-03-28 Thread Russell Leggett
On Wed, Mar 28, 2012 at 5:19 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: I find this proposal backwards. It requires an expeession as the right hand side. Alex proposed something similar a long time ago. He suggested using '!' instead of '.'. This is important because the common use