-
Notifications
You must be signed in to change notification settings - Fork 75
Poll: Operator Syntax #51
Comments
|
|
|
|
|
|
|
|
|
Why is there not an option for:
This seems like the most natural approach. Throwing a . between ? and () or [] is very syntactically strange. |
@jrista Please see #5 (comment) and claudepache/es-optional-chaining#3 for additional context. The obvious solution is not an option. EDIT: Also, see #52 |
Thanks. |
I believe we have a clear winner here. Following Optional chaining in Swift and Safe Calls in Kotlin, |
For better or worse, specs aren’t decided by a popularity contest. |
Is it syntactically possible to allow this syntax? |
Probably, but Optional chaining has different semantics than current (I’ve proposed to use |
|
mentioned in #34 (comment) by @hax |
I think it's been established that there's likely no option able to achieve complete consensus
The question is: the most of who? Is the size of this group
I'm not intimately familiar with the inner-workings of TC39, but I'd venture to guess the answer is realistically 30-50 with strong emphasis on input from 1-4. If that's the case, I would hope that whomever is presenting this proposal next includes the results of this poll as significant evidence of the direction to take. In any case, I think it's important for this discussion to be clear about who exactly it is you're striving for consensus with. Knowing the answer to that, our expectations may be tempered. |
The two most popular choices are, at the time of writing:
The third one ( They are roughly the same two as in a previous poll, although in different order. (I say ”roughly”, because the choices in the previous poll had some differences relatively to this one.) It seems clear at this point that we’ll pick one of those two options. Which one, will not depend solely on popularity, since we should strive to have what is the best for developers, not what pleases them the most. |
Isn't what's best for developers the same as what pleases them the most, at least in the long term? Otherwise how could you possibly define "best"? Of course I accept that what pleases developers now may not please developers in the future, which is what I think your point is |
As a trivial example of dissonance between ”pleasing” and “best”, a developer may want For the particular case of Optional chaining, I am currently not sure what is the best. Different syntaxes, including |
"Headache" is not pleasing, so we are talking about the same thing, just from a longer term / wider perspective. Otherwise there is no way of measuring "best". The solution is probably to take a poll among those who have engaged fully in consideration & conversation about the various alternatives, which is what I think your point is. |
|
Just a general note, I think it's important to point out that the nullish coalescing operator implicitly depends on the result of this decision. For those favoring syntax that would result in using Between the options of Just some food for thought. |
Might be just me but I'm totally comfortable with |
If that's what we end up with, we can call it the Combover Zoidberg operator. |
Slight variation on @shannon proposal, leaving out the
|
@dwelle I think it's fine, but see #51 (comment) I have a bold/foolish suggestion :) . Would the committee please pick a syntax and move on? Those of us who don't like the committee's choice can write Babel plugins to give us our preferred operator :D . (Yes, I know forking a language is a Bad Thing. I also know that transpiling is here to stay, so perhaps we really could use it to relax some of the constraints.) |
@cxw42 if a syntax is picked, babel will drop support for the other ones - you won’t be able to use them moving forward. |
@Zarel no, anyone can write plugins for the syntax that Babylon supports. Babel intentionally does not allow wild syntax experimentation. Certainly you could fork, but you can do that now whether a decision is made or not. |
I’m a core maintainer on Babel: @ljharb is correct here. The parser is not designed for custom plugins, only the transformer. |
@jridgewell @ljharb Thanks - I learned something today! I'm signing off the thread - good luck to all! |
@jridgewell I agree use Babel for some arbitrary syntax variant is not a good idea, but just want to point out that babel parser also have a plugin architecture, just never expose it outside uptonow. I'm not sure whether expose such functionality is ok. At least anyone can fork babel if they really want 😅 |
why is everyone hating that suggestion? It wouldn't even need new syntax, like how about extending the (the whole point of optional chaining is to reduce clutter, otherwise i could just rewrite the whole expression on the right side of |
@hpoul If use a notation contains |
I really like the idea to use question mark, but I don't like this examples:
I do like this approach, but including the fact that there is a reason why it cannot be used (#51 (comment)), maybe there is a sense to use the same but with some other symbol? At this article which was mentioned above there are a lot of implementations for it from other languages and my proposition is to use some other symbol (from other languages implementations) instead of question mark. In this case this operator will be better identified for people who came from other languages (or work with other languages in parallel) and there will be no parse issue. So from other languages we can see that there are 2 suitable symbols for it: That is how it will look: |
@zmefz The subject has already been extensively discussed; many alternatives have been proposed, and none of them gained more favour than the currently proposed syntax. The issue is known since several years. For your particular suggestion, |
I think it's decision time. Cater to the developers of the future, not of today (and their "other language" biases), as it will be a decision forever, and JavaScript will be THE language (at least for the foreseeable future). Given that, I think the decision should be clear and obvious (at if not, at least make a decision). You have my regards |
I agree, we should resolve ourselves to the consensus which is to move on with just |
I don't know if this is your intention, but this would force |
Yes, you're totally right, I've fully forget about this operator. |
@ScottRudiger would you be comfortable to reveal the reasons for your thumbs down? I would benefit from knowing why I'm wrong, if so. Otherwise have a great day anyway |
@TheNavigateur You were thumbed-down because Claude's post right above yours already answers your post:
The thumbs-down is because if you won't even read the post right above yours, it seems unproductive to argue with you. You seem to be confused about the state of the proposal. You say things like "it's decision time", but decision time was months ago. We already decided, after five years of arguing. You haven't said anything new, only things that we've already thought about. We're aware that |
Maybe that this gh issue, and many others in this repository, could have already been closed as resolved. I was waiting the outcome of the March TC39 meeting, where they may decide to advance this proposal to stage 2, at which point I plan to do heavy housekeeping. |
Here is to hoping things go well in March! Really looking forward to this operator. :) |
Hey folks,
I wanted to pull out and highlight the options that have been raised in the syntax thread, as not all options were presented and they are now somewhat buried. Please use the response buttons to vote and keep comments related to syntax in #34
The text was updated successfully, but these errors were encountered: