The "Pipeline" Operator - Making multiple function calls look great

Alexander Jones alex at weej.com
Mon Dec 14 18:06:46 UTC 2015


Correct me if I'm wrong but doesn't your example here result in extra turns
of the run-loop, even for synchronous functions?

This whole thing feels a bit unilateral to me and at risk of
over-engineering a solution we'd maybe do well to consider what other
languages are doing, e.g. https://en.wikibooks.org/wiki/Haskell/do_notation

On Monday, 14 December 2015, Marius Gundersen <gundersen at gmail.com> wrote:

> Do we really need to add support for await in a pipeline syntax sugar when
> there already is a piping support in `.then()`? If you need to await
> something in that chain, then just use `.then()`.
>
> ```js
> let result = await fs.readFile('index.txt')
>   .then(aSingleParamFunction)
>   .then(anotherSingleParamFunction)
>   .then(x => multiParamFunction(x, 10));
> ```
>
> I really don't see much gain in adding this syntax when there is already a
> FBS proposal that covers most of the cases. The pipe operator only supports
> single param functions. With multiple params you either need to use
> fat-arrow (while FBS handles multiple params) or you need a special
> function that is curryable. So now we either need functions that is
> curryable (for |>) or a function that relies on the `this` value (for FBS),
> so libraries will probably need to be specially written for whichever
> proposal is added to the spec. It looks to me like FBS adds a lot more
> value than |> does.
>
>
> On Mon, Dec 14, 2015 at 2:05 PM, Bruno Jouhier <bjouhier at gmail.com> wrote:
>
>> `await` could be handled by with contextual lexing: handling `|> await`
>> as a single keyword.
>>
>> Another solution would be to collapse the two into a variant of the
>> pipeline operator: `|await>`, `|!>`, ...
>>
>> This could be an opportunity to revive the syntax sugar that was proposed
>> in http://wiki.ecmascript.org/doku.php?id=strawman:concurrency
>>
>> ```js
>> // concurrency strawman
>> lines = fs.readFile!('./index.txt').split('\n');
>> // pipeline operator
>> lines = './index.txt' |!> fs.readFile |> str => str.split('\n')
>> ```
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151214/11103f02/attachment-0001.html>


More information about the es-discuss mailing list