What's so painful about just doing `exclaim(capitalize(doubleSay("hello")));`? Why introduce needless syntactic sugar that'll only confuse people about how UNIX pipes work?
To understand the nesting you have to evaluate the functions in the opposite order than you're reading them: exclaim capitalize doubleSay Sure, some of us has spent 20 years doing this so it's easy, but you can't deny that this is far nicer to read: doubleSay capitalize exclaim I'm a big fan of Fluent Interfaces, so I use this construct fairly often: "hello".doubleSay().capitalize().exclaim()
ES7 Proposal: The Pipeline Operator
31–40 of 78 posts
Re: ES7 Proposal: The Pipeline Operator
#32If we're going to do this operator, I would prefer a regular arrow: import { sortBy, filter, map } from 'array-like'; let names = document.querySelectorAll('.entry') -> sortBy('title') -> filter(entry => entry.getAttribute('data-url') in whitelist) -> map(entry => entry.getAttribute('name'); I personally find this more readable than either the bind proposal (which looks too much like a property access, and not enough…
> I personally find this more readable than ... the proposed pipeline operator, which doesn't have an immediate meaning to my eyes. Really? have you never seen unix pipes?
Re: ES7 Proposal: The Pipeline Operator
#33If we're going to do this operator, I would prefer a regular arrow: import { sortBy, filter, map } from 'array-like'; let names = document.querySelectorAll('.entry') -> sortBy('title') -> filter(entry => entry.getAttribute('data-url') in whitelist) -> map(entry => entry.getAttribute('name'); I personally find this more readable than either the bind proposal (which looks too much like a property access, and not enough…
that won't play nice with coffeescript!
Re: ES7 Proposal: The Pipeline Operator
#34If we're going to do this operator, I would prefer a regular arrow: import { sortBy, filter, map } from 'array-like'; let names = document.querySelectorAll('.entry') -> sortBy('title') -> filter(entry => entry.getAttribute('data-url') in whitelist) -> map(entry => entry.getAttribute('name'); I personally find this more readable than either the bind proposal (which looks too much like a property access, and not enough…
let names = document.querySelectorAll('.entry')
.sortBy('title')
.filter(entry => entry.getAttribute('data-url') in whitelist)
.map(entry => entry.getAttribute('name');Re: ES7 Proposal: The Pipeline Operator
#35I feel like that just confuses things for no good reason. It's no fewer characters than parens but provides as I see it less clarity.
What happens is much easier to read if you know what the operator means.
The only way the old way has more clarity is in the "we are already familiar with it" way. In any other way, this method trumps it.
Re: ES7 Proposal: The Pipeline Operator
#36I don't entirely understand where this gets me that promises don't.
This proposal is about function application.
Re: ES7 Proposal: The Pipeline Operator
#37If we're going to do this operator, I would prefer a regular arrow: import { sortBy, filter, map } from 'array-like'; let names = document.querySelectorAll('.entry') -> sortBy('title') -> filter(entry => entry.getAttribute('data-url') in whitelist) -> map(entry => entry.getAttribute('name'); I personally find this more readable than either the bind proposal (which looks too much like a property access, and not enough…
Why the arrow? That works just fine with a dot. let names = document.querySelectorAll('.entry') .sortBy('title') .filter(entry => entry.getAttribute('data-url') in whitelist) .map(entry => entry.getAttribute('name');
(and of course 'sortBy' is nonstandard)
Re: ES7 Proposal: The Pipeline Operator
#38I feel like that just confuses things for no good reason. It's no fewer characters than parens but provides as I see it less clarity.
I think the clarity comes from the reading order. str |> method1 |> method2 |> method3 vs method3(method2(method1(str))).
Seriously, this just seems like syntax sugar that just isn't needed. I get that you might not think it's elegant, but is anyone seriously troubled or confused by method3(method2(method1(str)))? How would the pipeline syntax help here?
Re: ES7 Proposal: The Pipeline Operator
#39If we're going to do this operator, I would prefer a regular arrow: import { sortBy, filter, map } from 'array-like'; let names = document.querySelectorAll('.entry') -> sortBy('title') -> filter(entry => entry.getAttribute('data-url') in whitelist) -> map(entry => entry.getAttribute('name'); I personally find this more readable than either the bind proposal (which looks too much like a property access, and not enough…
And I want it painted green ;-)
> ... which doesn't have an immediate meaning to my eyes.
It's a matter of background. F#, Julia and Livescript have identical operators, likely among others.
https://msdn.microsoft.com/en-us/library/dd233229.aspx#Ancho...
http://docs.julialang.org/en/release-0.4/stdlib/base/?highli...
Re: ES7 Proposal: The Pipeline Operator
#40What's so painful about just doing `exclaim(capitalize(doubleSay("hello")));`? Why introduce needless syntactic sugar that'll only confuse people about how UNIX pipes work?
_(array)
.compact()
.map(function(x) {
return x * x;
})
.filter(function(x) {
return x > 100;
}).value()
(example from underscore/lodash)The problem with this is to be able to add a custom function to this pipeline, you have to extend the prototype of the library with your own functions, or re-implement it.
Extending the prototype is considered bad practice for a lot of reasons, for example due to polluting code in other modules or upstream changes breaking your code.
If instead of chaining methods we chained functions we are left with this awkward syntax:
custom(filter(map(compact(array), function(x) {
return x * x;
}), function(x) {
return x > 100;
}));
it's much cleaner to write it like this: compact(arr)
|> map(function(x) {
return x * x;
})
|> filter(function(x) {
return x > 100;
})
|> custom
The linked page has a nice example and explanation about this concerning promises https://github.com/mindeavor/es-pipeline-operator#sample-usa...