Live data from Hacker News

ES7 Proposal: The Pipeline Operator

github.com

71–78 of 78 posts

Re: ES7 Proposal: The Pipeline Operator

#71
post #67

Earlier quoted context omitted.

Extension methods only apply to instances and they must be declared explicitly. This syntax can be used anywhere as long as the types signatures of the functions are conducive to the chaining.

Not sure what you mean with applying only to instances, in which case couldn't you use an extension method? If you own the code making a function an extension method seems not a big deal. If you want to invoke a static function you don't own the code for then you could have a generic wrapper extension method which admittedly would probably look rather clumsy and nullify the desired gain in readability.

But you have to write them before using. It's not needed in case of the discussed feature.

Re: ES7 Proposal: The Pipeline Operator

#72
post #26

Earlier quoted context omitted.

Can you elaborate on the rough seams between JavaScript and "full on functional"? I'm not a believer in the FP vs. OO religion, and have historically been skeptical of the bind operator. That said, I think that both composition via objects and composition via functions have their place. The pipeline operator attempts to make composition via functions more readable (left-to-right instead of right-to-left) and unless y…

js objects are mutable; utliliy libraries like underscore, lodash, jquery, do not provide purity guarantees, they export impure functions that mutate objects (e.g. https://lodash.com/docs#merge ). When we start leaning heavily on function composition to build our abstractions, we simply must have purity guarantees for everyday utilities or everything falls apart. So to go "full-on functional" in javascript means we n…

Are purity checks that hard to implement?

I don't know much about this...

Check that the function only writes on local variables and only reads closure variables and only calls other pure functions.

Re: ES7 Proposal: The Pipeline Operator

#73
post #65

Earlier quoted context omitted.

Briefly, you can look at it through the prism of equality. In javascript, 1 === 1, and "foo" === "foo". However, [] !== [] and {} !== {}. This is because in Javascript, like in Java, there is a distinction between value types (essentially, simple primitive values like numbers and strings) and reference types (collections - arrays and objects). When you assign an array to a variable, you are actually pointing the vari…

(you're replying to the guy who wrote Ember.js)

I totally didn't see that. Usernames are too small on this damn website.

Re: ES7 Proposal: The Pipeline Operator

#74
post #44

Earlier quoted context omitted.

Clojure is a functional language, so it meshes well with the rest of the syntax, but in javascript's case it's just syntax bloat. It's going to be really jarring in the middle of regular imperative code, and it's not going to be too far removed from cout

Whether `|>` would mesh with your code depends on the code that's already there. Doesn't seem fair to shut down this proposal because you happen to write and work with imperative code, a style that Javascript and modern abstractions are moving away from. In fact, the Javascript hack to get a pipeline-like style is to make some opaque wrapper object that you can chain method calls onto like `_.chain(a).b().c().d().val…

# Why not ## Lodash `_.flow(b,c,d)(a)` // left to right `_.compose(d,c,b)(a)` // right to left `_.flowRight(d,c,b)(a)` // right to left `_.backflow(d,c,b)(a)` // right to left

## RamdaJS `_.pipe(b,c,d)(a)` // left to right

# But why are we inventing so many ways of doing forward, backward function application and composition.

Aside: I've never found an application of lodash `_.chain` that couldn't be expressed in a better way.

Re: ES7 Proposal: The Pipeline Operator

#78
post #33

Earlier quoted context omitted.

CoffeeScript should have thought of that ;)

JS var result = exclaim(capitalize(doubleSay("hello"))); ES7 Proposal: The Pipeline Operator var result = "hello" |> doubleSay |> capitalize |> exclaim; CoffeeScript result = exclaim capitalize doubleSay 'hello' I'll take CoffeeScript.

+1
Post reply on HN