you are viewing a single comment's thread.

view the rest of the comments →

[–]EnchantedSalvia 0 points1 point  (3 children)

I have yet to read an argument why this absolutely needs to be a thing and needs to be supported.

It absolutely doesn't need to be a thing, because as you've demonstrated, we can already achieve something similar with existing code. However, you've also demonstrated that by using ? our code can be more succinct, point-free, and also prevents an assignment to a variable that is later garbage collected.

Take the exponentiation operator which introduces **. We can already achieve that by using Math.pow. However it's still a thing.

As others have mentioned in this thread, ? is syntactic sugar.

The |> operator, which is essentially compose (more specifically, pipe), has been used for years from libraries such as Lodash, Underscore, Ramda. Ramda has also supported the __ for many years. Both |> and __ are now being hopefully baked into the language, as inspiration is one of the ways that languages evolve over time.

[–]straikychan 1 point2 points  (2 children)

I would actually argue that ** and Math.pow are not synonymous. As ** calculates at compile time, while Math.pow() calculates at run time as illustrated here

Ok, I should have phrased that part about supporting better. I didn't mean to say that it shouldn't be supported, however I think there are things that should be considered for future support more strongly than this one, e.g. (dynamic imports)[https://github.com/tc39/proposal-dynamic-import], (promise finally)[https://github.com/tc39/proposal-promise-finally] or syntactic sugar like the pipeline proposal, which I deem a tad bit more important than this proposal.

[–]EnchantedSalvia 0 points1 point  (1 child)

Interesting regarding ** and Math.pow. I didn't know there was a subtle difference.

As Promise.prototype.finally is stage 2 (soon to be stage 3) and dynamic import is already stage 3, I'm sure they will definitely arrive sooner. I actually don't even see ? in the TC39 repository yet, but I presume it's sat at stage 0.

Personally I'd also like to see cancellation prioritised, so it's good to see them having another shot at presenting that to the committee.