Scoped binding of a method to an object

Benjamin (Inglor) Gruenbaum inglor at
Tue Oct 15 14:08:11 PDT 2013

Thanks, this clarifies things (the difference between having `this` and a
first argument is really not that big here at all imo and converting
between them two is easy).

 > What is your ideal SOE form? Because my guess is that I can get it darn
close with ::

It does seem a lot simpler than actual extension methods with scope
resolution, my only problem with it is the polymorphic case (the equally
silly Cat/Kitten case in my email to Brendan). I'll ask around and have
better conclusions but it does seem to have better feedback from
developers, I think use cases like chaining are good for the wiki page.

On Wed, Oct 16, 2013 at 12:00 AM, Russell Leggett <russell.leggett at
> wrote:

> On Tue, Oct 15, 2013 at 4:28 PM, Benjamin (Inglor) Gruenbaum <
> inglor at> wrote:
>> Wait, I think maybe I did not understand what you meant before.
>> Are we talking about using `::` for infixing the first parameter of the
>> function? As in `func(a,b,c)` being the same as `a::func(b,c)` ?
> Not exactly. See the proposal
> "Essentially, e1::e2 is equivalent to do { let obj=e1; e2.bind(obj) }"
> Or, in the case of an immediate call, it skips the bind and just does a
> In other words,
> obj::fun(a,b) is not the same as fun(obj,a,b). Its,a,b).
> The important distinction is that the function being called is expecting a
> |this| as opposed to an extra first argument. This is reason I called it
> "underscore2" - Brendan picked up on that calling it OO underscore.
> Functional purists can argue with the approach, but it would let you write
> functions exactly as though they were extension methods - using |this|
> where appropriate.
> The following is a somewhat silly example based on the SOE proposal
>     module Collections {
>       export {
>         where: Array.prototype.filter,
>         select:
>       }
>     }
>     module LolCatzDotCom {
>       // imports Array.prototype extensions where and select into this
> module
>        import {where,select} from Collections;
>       var allCatz = someArrayValue;
>       // Array extensions are in scope
>       var cuteCatNames = allCatz::where(cat => cat.isCute)::select(cat =>
>     }
> If you still don't get it, give me an example, and I can probably show the
> :: equivalent. What is your ideal SOE form? Because my guess is that I can
> get it darn close with ::
> - Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list