-
Notifications
You must be signed in to change notification settings - Fork 108
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
Proposal 4: Smart Pipelines, Explainer + Spec #100
Comments
In the explainer I see the following example: promise
|> await #
|> # || throw new TypeError()
|> doubleSay(#, ', ')
|> capitalize
|> # + '!'
|> new User.Message
|> await stream.write Note that in JS let userMessage = new User.Message;
// equivalent to:
// let userMessage = new User.Message(); At a more general level, do you think that |
@zenparsing: Once the smart body syntax’s rule is internalized, The rules can be fully stated in three sentences:
The decision was that completely nullary expressions such as In the same way, |
I don't think they present a "problem" for F#, b/c in F#, the new instance would be slotted into the pipeline, similar to putting a called function in there. If you wanted to create a new instance in the middle of the pipeline, an arrow function would be needed: x |> x => new User.Message(x) There aren't (and probably shouldn't be), special rules around @js-choi Does your proposal require |
Nevertheless, we're suggesting that We can't assume your paren-free arrows. If a user wanted to feed the pipeline value into a constructor, can't we expect at least some users to try: arg
|> new User.Message; This seems like a minor footgun to me. |
@zenparsing I'm still pushing for this as a solution to get them back. Even if we can't get them back, the response is the same. In F#, I don't expect that to be something they'd try anymore than they'd expect this: x |> doSomething(123) to do something other than use the return value of |
For smart pipelines, the bare style is intended to be constrained special syntax that is not interpreted in the same manner that arbitrary expressions are—special, in order to optimize for three common use cases—constrained, in order to limit the additional complexity that it brings and force the developer to use topic style if they want anything other than those three use cases. The developer must opt into the special syntax. Either or both of the But nevertheless, either or both of the The goals of the smart-pipeline spec, as it is currently written, agree with @mAAdhaTTah and Proposal 1: F-sharp Style Only, in that they optimize against the rare use case |
As an aside:
It does not, insofar that “fully” functioning here indicates a minimum baseline of usefulness for the developer.
|
What about banning a bare It's only a minor inconvenience, and the error message could say |
@gilbert: That solution is possible, but the solution would invalidate a useful heuristic of the bare style: “Bare style never has parentheses (or brackets, braces, or any other operators other than I did not anticipate that the special bare form for unary constructor calls (and, by extension, the special bare form for awaited unary function calls) would be at all controversial. They are optional features of the Core Proposal’s bare-style syntax, which is merely a special treatment of simple chains of identifiers and |
I should be more clear. In my mind To pipe a value into |
@gilbert: Indeed, It is for that reason that the current smart-pipelines spec makes This is analogous to how the current smart-pipelines spec also makes |
|
@gilbert: |
I have two concerns:
For the second point, you suggest a I think a #-style function should be defined before a #-style pipeline because it could be used everywhere. In order to keep things consistent we should make both If we keep
|
Could something like this be possible?
|
Hey, @hlehmann; thanks for reading the proposal.
This is incorrect. For each step of a pipeline, its choice between topic or bare style depends only on whether the step is an identifier (or a chain of identifiers and
I’m a little confused by this part, sorry.
Here, you’re referring to Additional Feature PF, which I want to stress is an optional annex separate from the core proposal. Assuming that Feature PF got support from TC39, I wouldn’t want it to reuse
This would not work under the current proposal’s rules, because Consider that this is equivalent to
Similarly, with
…Instead, you would want to use Thanks again for reading the proposal. Hopefully this answered some of your questions. |
Thanks for the clear answer, especially about all the syntax constraints. I have been a bit confuse by the Additional Feature PF as you define at an extension of the smart pipeline ( My question is more about is If something like But my general understanding is that I can oversimplify all this by:
|
Edit: Elixir's I'm finding from talking with others that there's concerns this may be trying to do too much. They aren't quite as vocal as the rest of us, but I feel I should at least give them a voice here, to let them know they're not alone. Here's my personal opinions on the proposal at a higher level, and they're mostly expanding on existing concerns I've heard elsewhere.
Now, back to the alternatives:
For my personal take, I say avoid the method-based chaining (it has the strongest cons and far fewer pros), but the other two are still very much viable. |
Thanks, @isiahmeadows, for the detailed comment. Sorry for the delay in responding. I’ve been busy out of town, and I’m unfortunately still busy with a major transition, so I’ve had to disengage for the past weeks. A lot of discussion has been happening here. That’s a good thing, and I am thankful, but it’s also overwhelming, so my apologies if I can’t respond to everything here, at least for now. I want to focus on developing the Babel plugin instead during my free time. As a general response, I want to say that concerns are understandable, and I appreciate your bringing them up here. There are some claims that I agree with, and some claims here that I either do not agree with or disagree with. But in any case, there is a lot here, so it will take some time for me to address all your points. I also want to note that, until a comprehensive study on real-world code is conducted, all possible discussion about the proposals is just theoretical. To this end, @mAAdhaTTah and I are together developing a Babel plugin. I do plan to implement many possible variations of smart pipelines, so that all of them may be tried by switching configuration options. But until that Babel plugin is written, or until someone else tests the different pipelines on a corpus of actual real-world code, all of this discussion is theoretical. I, @mAAdhaTTah, @littledan, and Yulia Startsev of Mozilla have also been discussing running usability studies on JavaScript developers or real-world code in many coding styles, though those too would not occur soon. Later, when I have time, I will do my best to respond point by point—merely theoretically, of course. Thanks again for the detailed comment. |
If this is the plan, maybe we resolve #104 by implementing both and experimenting in a babylon fork. Then babel doesn't have to guarantee as much. |
I don't think a proliferation of lots of forks would be best here, as it would make it hard to see the cross-cutting effects of several proposals that are in flight. If we use a separate branch, I think it would be best to have one big "experimental" branch where we land all early proposal variants with different runtime flags. |
Sorry if I wasn't clear; my intention was one fork with all the experimentation (it looks like we've got 2 potential variants for each), while babel proper just maintains the current "minimal", and we only upstream the result if / when we advance to Stage 2. We'd provide a single babel plugin, which tells babel to use our fork and exposes all the different configuration flags. |
I may be late to the party, because the last comment s more than a year old, but here is another idea, which was almost mentioned above, but not quite. Part 1: Part 2: an expression The problem with part 2 is, how If everything was fully typed, I'd propose Fortunately
This is just an idea and not fully thought-out proposal and I expect that there are a lot of things which I did not think about, but in general I think the idea simplifies the pipeline-semantics and generalizes |
@thraidh You should checkout JS Choi's follow-on proposals for the smart pipeline, as it would address some of those concerns: https://github.com/js-choi/proposal-smart-pipelines |
@mAAdhaTTah I know. I was trying to improve upon that by removing the need of a distinction between "topic style" and "bare style", thereby simplifying the pipe semantics and generalizing the |
Has "auto-awaiting" been discussed somewhere? I.e. any LHS of a pipe which returns a promise is always |
@thraidh Sorry, to clarify: I meant the "additional features", like Pipeline Functions address some of those use cases. He's designed the Smart Pipeline to be a base for a whole constellation of usages, some of which I think address some of your thoughts here? But maybe I'm misinterpreting.
Probably, yes. It hasn't been discussed anywhere I can recall. |
@mAAdhaTTah Thanks! I actually missed that or did not grasp the implications. With that additional feature the result would be close enough to my idea, so that further discussion would only be a matter of opinion. |
After talking more with @tabatkins and @littledan, we’ve decided to archive the smart-mix pipes proposal in favor of a simpler Hack-pipes proposal. The latter is a subset of the former. A new Hack-pipes proposal is at js-choi/proposal-hack-pipes. There’s also a Hack-pipes spec. This proposal’s readme and wiki have been updated to link to these and deprecate smart mix. There has already been work done in Babel by @xixixao in babel/babel#11600, which we can work on merging into Babel later. |
I’d like to ask for feedback/criticism on a detailed explainer and specification for Proposal 4: Smart Pipelines plus several possible extensions to it.
In particular, I’d like to know whether their current organization is too confusing. There is a simple “actual” Core Proposal, plus several optional Additional Features that extend the Core Proposal and address several other use cases.
I should stress that the Additional Features are optional and mutually independent. They show the potential of simply extending the core proposal to handle other use cases (such as composition, partial application, and method extraction). And I’ve attempted to keep the core proposal forward compatible with all of the additional features.
But I don’t want to scare people with too many new features at once, though. All of the Additional Features are optional. I’ve currently integrated the Additional Features in the same documents because the Additional Features demonstrate the conceptual generality of the Core Proposal. I could separate them into other documents if it would be better.
See also #75, #89, #91, #95, and #96.
Thanks for your time!
The text was updated successfully, but these errors were encountered: