3 ms·
Wouldn't it be better to use '->' as the operator? This is about dataflow so an arrow would represent that nicely. Whereas '|>' doesn't really "mean" anything
by galaxyLogic 4y ago
Wouldn't it be better to use '->' as the operator? This is about dataflow so an arrow would represent that nicely. Whereas '|>' doesn't really "mean" anything. An arrow means that something flows in the direction of the arrow.
- vorotato 4y agoI also pushed for this in TC39 which was shut down for seemingly no reason. Since only one language with almost no user base uses |> to mean expressions, people are guaranteed to get the wrong idea about how it works. It almost seems like intentional misleading.
- BeefWellington 4y agoNot only that but I can't be the only person who finds -> vastly easier to type than |>.
- hajile 4y agoSure, but I'd rather reserve that for a pattern-matching switch statement.
- galaxyLogic 4y agoWhy not use |> for that?
- hajile 4y agoIt's more common for pattern matching Java's new syntax, Erlang, Elixir, StandardML (fat arrow), F#, Kotlin, Ocaml, Haskell, Rust (fat arrow), Ada (fat arrow), Scala (fat arrow), Zig (fat arrow), and probably a bunch of others too. That's a lot of prior art for people to be comfortable with and as the fat arrow already has another meaning, overloading it in pattern matching might complicate things.
- galaxyLogic 4y agoRight but then it would not be the same as in those other languages which use fat arrow anyway. Another syntax for pattern-matching could be simply ':' instead of the arrow. In the early days of Smalltalk the Smalltalk return statement was simply '^'. That could also be suitable for pattern matching. The idea would be that the switch statement returns something meaning pushing it up from the expression to whoever called it. So '^' might be good for that. Whereas pushing the results to the right to the next expression could be ->. Just my preferences.