3 ms·
Hack (Facebook's PHP fork) has this feature. It's called pipes [1]: $x = vec[2,1,3] |> Vec\map($$, $a ==> $a * $a) // $$ with value vec[2,1,3]
by jmyeet 2y ago
Hack (Facebook's PHP fork) has this feature. It's called pipes [1]:
$x = vec[2,1,3]
|> Vec\map($$, $a ==> $a * $a) // $$ with value vec[2,1,3]
|> Vec\sort($$); // $$ with value vec[4,1,9]
It is a nice feature. I do worry about error reporting with any feature that combines multiple statements into a single statement, which is essentially what this does. In Java, there was always an issue with NullPointerExceptiosn being thrown and if you chain several things together you're never sure which one was null.
[1]: https://docs.hhvm.com/hack/expressions-and-operators/pipe https://docs.hhvm.com/hack/expressions-and-operators/pipe
- alganet 2y agoWait. Isn't that already solved in Java? Optional, Mono, Flux, etc. I remember being able to deal with object streams with it quite comfortably.
- jmyeet 2y agoAny function that can return an object in Java can return a null. Nullability not being part of the type system I think is a design fail.
- alganet 2y agoYeah, so the null checks become annoying if you use only language fundamentals. Java has a culture of having a layer above fundamentals. We're past all that already. I am discussing the ergonomics of their null checking APIs, particularly in the context of pipelining (or streaming, in the Java world). I find them quite comfortable.