-
Notifications
You must be signed in to change notification settings - Fork 15
Disallowing arbitrary expressions as a pipeline function #2
Comments
(To explain myself, I was sort of picturing that any expression which didn't contain |
Arbitrary expressions are allowed as pipeline functions—in explicit topic style. In general,
I want to minimize lookahead, avoid garden-path syntax, and optimize for syntactic locality. This went consideration especially into distinguishing bare style versus topic style. The problem with having determination of pipeline style depend on the presence/absence of
Bare style does not address auto-curried functions, no. But topic style covers them. This is intentional, because, in general,
I probably should add this example to the proposal before TC39 next week, too. Hopefully, this reasoning makes sense. |
In addition to @js-choi's reasoning, note that the "lack of a topic reference implies that it's an expression that will evaluate to a function" means that It's also in direct conflict with the other nice grammar forms of bare-style; In other words, you'd lose all three of these cases being easy (you're forced to use topic-style instead), in return for certain FPish cases being easier. (As an inveterate Lisper, even tho it pains me, I must admit that point-free stuff is less relevant and useful than methods/constructors/async/future stuff.) Neither approach makes any cases impossible, you just have to remember to put a And I find the "no foot-shooting" aspect extremely relevant for |
@tabatkins Thanks for the comment! I’m interested in your perspective about better communicating these aspects of the proposal in my explainer, if you have any ideas. Maybe expanding the syntactic locality goal section, or adding some paragraphs about method calls to the motivations, core proposal section… |
@tabatkins Also, per #3 I might separate the bare constructor call and the bare awaited function call from the core proposal to new additional features. If you have an opinion about that, feel free to chime in at #3. |
I think those do make sense to be a (single) separate feature, yeah; it makes it clearer that this is a syntax extension point that can take on new stuff in the future too. The The third paragraph of syntax locality could use some expansion into a listing of the cases you talk about here: the existing talk about garden-pathing to figure out which form it's in; the For that last one, pointing to other langs with pipelines, and pointing out that they differ in how they interpret this case (Elm, for example, interprets |
@tabatkins I don't think that's true about the current pipeline specification text--I think it would use the right receiver. |
I'm curious how it would do so! Adding special parsing rules, distinct from normal JS, in what is otherwise a perfectly ordinary arbitrary expression, doesn't seem like the best idea. In particular, I'd be very unhappy if This proposal makes it so that the latter two cases are early syntax errors, and when you fix them by adding a topic reference, they work in the expected way, with (In other words, I really think the anti-footgun measures of this proposal are valuable here, even if arbitrary-expression-form somehow handled all the use-cases otherwise.) |
Because fundamentally, we're not passing the method into something else to use; it's getting applied immediately. There's isn'y really a fundamental difference between Also, The behavior is consistent across all the proposals at this time, and is currently specced in the "minimal proposal" in the repository at this time. |
@mAAdhaTTah is correct in that However, In addition, the semantics of
I probably should add this table to tc39/proposal-pipeline-operator#108 and to the wiki. |
@js-choi |
Okay, so the minimal proposal desugars (I didn't realize that Okay, then that does seem to solve the fragility issues at least somewhat, nice. |
@tabatkins: I hadn’t realized this until recently myself: I’m really glad that this fragility problem doesn’t seem apply to Proposal 1—though it does put a lot of the burden of its being useful on @rbuckton’s partial-application proposal, which smart pipelines would also subsume with a similar amount of syntactic complexity. Smart pipelines also try hard to prevent visual ambiguity, requiring
|
…nt insertion See #2 (comment) t-373493849.
Wait, your |
@tabatkins Yeah, that table is for the core proposal only…I should note there and in the wiki that it is allowed with Additional Feature BA. Edit 1: And I should add some entries for construction too, which exhibit more differences between Proposal 1 and 4. Edit 2: Edits done in the wiki, #2 (comment), and #6 (comment). |
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. |
Interesting idea here, with the "don't shoot yourself in the foot" reasoning. I agree that I'd rather not encourage currying as the main way to use the pipeline operator, but it seems like this syntax disallows that entirely. Is this intentional or desired?
The text was updated successfully, but these errors were encountered: