-
Notifications
You must be signed in to change notification settings - Fork 15
Bare constructor/awaited function call #3
Comments
Arbitriary expression are allowed on the right-hand sides of pipeline expressions, as per #2 (comment). (I do need to reword how I communicate this, to avoid similar confusion in the future. I would be interested to know how I might do this, from your perspective.) As I mention in this es-discuss post a few days ago, the topic syntax is expected to be used most often, as it supports arbitrary expressions. The bare syntax is only meant to optimize for unary functions, but in the end it is only a convenient abbreviation for topic style.
But I have been considering for the past week to separate bare constructor calls and bare awaited function calls from the Core Proposal, into their own Additional Features BC and BA. I would change the examples in the Core Proposal that use bare constructor calls and bare awaited function calls so that they use topic style |
From #2 (comment) by @tabatkins:
|
Ultimately this is a value judgement about the relative worth of making different things easier.
(For all of these, if we also don't have topic-style, then the alternative would have to be written as an arrow function.) Additionally, in case 2, if we have bare-style and you accidentally try to write On the other hand, in case 3, 4, and 5, if we go with expression-style, then writing out the simple version will silently be interpreted as the wrong thing, either raising a runtime error or just doing confusing things. As we find more function-call patterns that could benefit from shorthanding, bare-style can continue to grow, keeping things easy to use. Expression-style can't; at best we just continue to get more possibly-confusing cases. @littledan, your current proposal using expression-style tries to solve the It doesn't even try to solve methods or constructors yet, tho presumably it could add further special cases to make that work. That just means more possibility of confusion, tho, when people accidentally step outside the blessed expression-shape and accidentally fall into arbitrary-expression territory again. I think this would be especially bad for methods - exactly how much variance would be allowed? Would |
@tabatkins: Note that there have been some recent changes in the original pipeline proposal, as well as @mAAdhaTTah’s Proposal 1. See babel/babel#7458 for the discussion from which those changes emerged. See babel/proposals#29 (comment) and the slideshow for next week’s meeting for a summary. Basically, the fragility problem in #3 (comment) no longer applies to The fragility problem does also still apply to both the original proposal and Proposal 1 in their special casing of method binding. We’re calling the original proposal the “minimal proposal”, and it forbids In contrast, @mAAdhaTTah’s Proposal 1: F-sharp Style Only with Bare Await, does address Both the original/minimal proposal and Proposal 1 might also have special casing for method binding, in which case the fragility problems in #3 (comment) do also apply. I need to recheck the original/minimal proposal’s spec. As for Proposal 1, @mAAdhaTTah is in the middle of writing its spec, and he said he plans to make a special case for method binding. If you have time, take a look at the slideshow for next week’s meeting, which is now available from the TC39 agenda. @mAAdhaTTah is also planning to update the original proposal’s readme and its wiki with the new plans (for which I am very grateful). |
Anyways, I’m still working on separating bare awaited function calls and bare constructor calls into their own additional features. @tabatkins, you mentioned that you think they should be grouped together in one additional feature rather than two (“I think those do make sense to be a (single) separate feature, yeah”). Was there any particular reason why? |
Also relevant: tc39/proposal-pipeline-operator#100 (comment) by @zenparsing. |
You might want to leave this bug open for further discussion on the feature. |
Technically they could be separated, sure, but they seem very similar in practice - once you're allowing special keywords in bare-form, it makes sense to allow more. |
@tabatkins: Yesterday I couldn’t come up with a good name for a feature with both bare awaited calls and bare constructor calls, so I pushed a change that puts them in separate additional features. If you get a chance to glance over the new explainer, let me know if you feel that I should still combine them into one section. Thanks! Maybe the name “Bare Extras” could have worked… |
Bare style is the obvious and purely instinctive way of piping something, getting rid of verbosity and currying 🤔 const add = a => b => a + b
1 |> add(1) // should print 2 isn't using bare style by default and using topic only if a |
Thanks for the issue; sorry about the delayed reply. After talking more with Tab Atkins and Daniel Ehrenberg, we’ve decided to archive this proposal in favor of a simpler Hack-pipes proposal, which is a subset of this proposal. Feel free to open a new issue in the new proposal’s repository if you think it still applies. |
I'm surprised by the inclusion of this construct. It seems a bit complicated to me, and it ends up necessitating disallowing arbitrary expressions on the right hand side of a pipeline (#2). I can see that it's used in some of your examples, but I wonder if it would be OK to just include an explicit
(#)
for these.The text was updated successfully, but these errors were encountered: