rescript-association / reasonml.org

Deprecated in favor of rescript-lang.org
MIT License
125 stars 34 forks source link

Document about pipe last and guide that it's usage is discouraged. #177

Closed wontheone1 closed 4 years ago

wontheone1 commented 4 years ago

I learned that using pipe last operator (|>) is discouraged when compiling to JS.

Quoting @ryyppy

the conclusion for when to use pipe-first / pipe-last is: if you are using ocaml, you might want to use pipe-last, bc most apis are t-last. For bucklescript codebases, always use pipe-first, because it helps the compiler to eliminate runtime currying and it's also easier to map to JS apis due to their t-first nature

However, as long as this is legally compiled by the compiler, we still need to have documentation explains the syntax and why it is discouraged.

And other languages have both pipe operators too and users of those languages will start wondering what ReasonML pipe last operator looks like and waste time searching for it and they have to figure out in the wild internet about this syntax and they are discouraged. (e.g. in Clojure, both pipes are called thread macro and they don't have run time penalty and it's completely normal to use both)

ryyppy commented 4 years ago

Done!