Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Piping subresults between functions really doesn't get much better in any language

Piping operations like this can also be found in OCaml, F# and Perl6.

For eg. in Perl6 this is called a Feed Operator (http://perlcabal.org/syn/S03.html#Feed_operators) and your example would look like this:

  a ==> h ==> g ==> f;


Yes, many languages support something eqivalent. Classically object oriented languages not the least:

a.h().g().f()

I feel that prefix notation is one of the greatest impediment to the uptake of Lisps. And I think it's important to underscore that you can (idiomatically) choose prefix, postfix or infix depending on the character of your problem.

If the code is (unnecessarily) hard to read, then express it differently. The language encourages it.


Actually the equivalent of the above Perl 6 code would be:

    f(g(h(a)))
It can get kind of gnarly when any of the values are non-trivial.


Translated directly, yes.

But when you have objects and no piping operator, library designers will often choose to implement pipe flow as method chaining. See e.g. jQuery, Scala's collections or many ORMs, like SQLAlchemy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: