Scoped binding of a method to an object

Brendan Eich brendan at
Tue Oct 15 11:30:51 PDT 2013

Russell Leggett wrote:
>         The big issue I see here is chaining.
>          `_.reduce([1,2,3,4,5],x=>x%2 ===
>         0),x=>2*x),(x,y)=>x+y)`
>         Is a lot less readable than              
>          `[1,2,3,4,5].filter(x=>x%2===0).map(x=>2*x).reduce((x,y)=>x+y))` 
> P.S. This really doesn't look too shabby to me:
> import {reduce,map,filter} from "underscore2";
>     [1,2,3,4,5]::filter(x=>x%2===0)::map(x=>2*x)::reduce((x,y)=>x+y))

Right, I think :: beats _. any day :-P.

Seriously, using underscore.js's _. is kind of sandbagging. Allen's 
right, FP-style looks fine but composes inside out rather than via 
chaining (FP'ers like this). No need for this or dot, if you can make 
the world (including built-ins) have this style of API.

Using your proposed "underscore2" (OO-underscore?) with :: is no more 
verbose than underscore.js (underscore1), and it has the chaining not 
inside-out-composing win some may prefer.

We should not argue only about taste, and bind (::) has a champion and 
good rationale as an addition to the language.

What I think we should argue about is whether SOE that solves either or 
both problems (P1 and P2) I identified is even possible. Andreas's 
static-only resolution requirement is good. Anyone want to work on that 


More information about the es-discuss mailing list