-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
depercate bs.send.pipe in the future #2625
Comments
That'd be fantastic |
When should we use the OCaml For API providers: which one should I encourage the consumers to use? |
I would recommend avoiding the fast pipe entirely, since it mostly just causes confusion. But especially if you're writing anything not exclusively targeting BuckleScript, since the fast pipe is a BuckleScript-exclusive weirdness. Using the fast pipe prevents you from designing functions in a way that encourages function composition through partial application. For example, if you want to extract all the values from a list of options while providing a default value for those that are /* Reason */
items |. List.map(item => item |. Option.getWithDefault("default")); (* OCaml *)
items |. List.map (fun item -> item |. Option.getWithDefault "default"); But with functions designed for the normal pipe operator, by putting "t last", you can write: /* Reason */
items |> List.map(Option.getWithDefault("default")); (* OCaml *)
items |> List.map (Option.getWithDefault "default"); because This example is pretty trivial, but the gains quickly add up. There are very good reasons why functional languages have mostly standardized on |
Thanks! Now But what if I'm writing JS FFI bindings (hence exclusively BuckleScript), should I put the It seems like there are people advocating and converting their code with this "object-first convention" to make use of the BuckleScript fast pipe. |
I would still recommend not using fast pipe. There is a performance benefit to using Take it from Donald Knuth:
In web front-end programming especially, the time spent in code you write is usually dwarfed by the time spent updating the DOM. |
external ff : t -> int -> int = "" [@@bs.send]
let ff a b = ff b a I don't really mind the performance cost. |
We plan to make the external FFI handling logic simplified in the core, but it is not done since it may break some existing code. |
I would love to see those lots of benefits clearly explained sometime. The only rationale we've gotten so far, as far as I'm aware, is this comment and the thread that follows, which 1. doesn't really explain much and 2. ignores any criticism and concern raised. You can't expect anyone to "agree" with you when you go about it like that, and I don't think it's going to help your cause to characterize those who therefore don't understand, or don't agree with whatever assumptions you're making, as potential flamers. |
@glennsl I think we already talked about it offline for more than several hours.
I already spent lots of time explaining this issue, let's agree to disagree.
|
A summary of what? This is just a reiteration of your original points, ignoring any criticism and concern that has been raised. You are intentionally misrepresenting the issue. Here's a summary of the other side:
What I'm asking for is a clear and thorough explanation that looks at all sides. Despite all the hours you say you have spent explaining this, you seem to be incapable of doing that. Why is that? Do you just not care? |
Mentioning Jane Street's practice of "t first" without mentioning they only use a single positional argument is indeed a bit misleading. They use the classic pipe operator everywhere. I'd love to have a BeltLabels module, you can take a look at Containers for an example of a stdlib that automatically generates both conventions: c-cube/ocaml-containers#233
|
Enough is enough. |
|
The work around is changing code from
to
With such change, it will not affect end users (slightly slower), eventually we want users just use bs.send with the new pipe syntax
The motivation is to reduce the complexity of FFI and maintainance overhead, but also encourage people to embrace t first convention
The text was updated successfully, but these errors were encountered: