Scoped binding of a method to an object

Allen Wirfs-Brock allen at
Tue Oct 15 10:31:56 PDT 2013

On Oct 15, 2013, at 9:44 AM, Benjamin (Inglor) Gruenbaum 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))` 

first let me do a slight rewrite of the above to eliminate some semantic noise:

 import {reduce,map,filter} from "underscore2";
reduce(map(filter([1,2,3,4,5],x=>x%2 === 0),x=>2*x),(x,y)=>x+y)

Nobody should be thinking of these as equivalent expressions of the same computation.  They aren't equivalent because the semantics of the identifiers "reduce", "map", "filter" are quite different in the two formulation.

They mean different things and when express this way it is pretty clear that they are different. I don't see how making them look more similar (while maintaining the semantic difference) would help with code clarity.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list