3 ms·
One of the things I dislike about function notation is that in f(g(h())) execution order is right-to-left. I like OO partly because execution order is writing o
by mdemare 1y ago
One of the things I dislike about function notation is that in f(g(h())) execution order is right-to-left. I like OO partly because execution order is writing order ( h().g().f() )
In Clojure I love the threading macro which accomplishes the same: (-> (h) (g) (f))
- dismalaf 1y agoIn Haskell there's also dot (edit - my bad, not dot, pipe) syntax which allows composing functions left to right. I believe Nim also has it. Just as a few more examples.
- _kb 1y agoI don’t think that’s correct. The dot operator is composition with the same semantics as when using normal math notation. (f . g) x is equivalent to f (g x)
- deleted 1y ago[deleted]
- projektfu 1y agof . g is still doing g first, then f, right? Haskell has pipelines in the Flow library. https://hackage-content.haskell.org/package/flow-2.0.0.9/docs/Flow.html https://hackage-content.haskell.org/package/flow-2.0.0.9/doc...
- dismalaf 1y agoOoops my bad. Been too long.
- valcron1000 1y agoNo need to import a third party library: you can use `Data.Function ((&))` for this: arg & f1 & f2 & f3
- paradox460 1y agoNim and other languages addressed that by making . akin to a pipe operator. It takes the left and sends it to the right, as the first argument