-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Issue with "Operator precedence": arrow function operator precedence #12914
Comments
Not sure. There is this note in the docs But then in various proposals you see things indicating that yes, it is in group "2". @wbamberg Thoughts? |
In this case according to standard ?: ternary is also not operator but conditional assignment... |
Possibly. I'm deferring to the experts - @sideshowbarker , @wbamberg do you have an opinion. I'd be happy to add this myself. |
Yeah,
In general, anything existing currently in that table that’s not an operator should be removed from the table — and certainly shouldn’t be used as a precedent for adding any other no-operators to the table. |
I'm concerned that removing operators from the table makes it less useful. Standard is needed for implementors, but what comes to users - it's very helpful to learn when parens are needed in case of => or ?: (which is conventionally called operator, regardless of particular name in spec). Afterall they account for precedence (unlike statements), eg. it's important to know that |
@sideshowbarker I think @dy makes a valid point - if you're a user you want to know the precedence of particular "thingies" (a technical term we use in Australia) whether or not the thingies are technically operators. So we can remove them but we need to provide some excellent and obvious linking to where the information is provided. Thoughts? |
For the purpose of a reference page, I'm also pro-including it. Maybe the page title doesn't accurately reflect its content in this case, but it would still be useful to know how tightly a particular construct—even
We should either include |
We could re-title (and redirect) the page. I guess we should. But then that presents the different problem of what title to give to that page. Back when I was thinking about this, I think one thing that came to mind was that some of the things people wanted to include in the table had to do with the language’s rules for order of evaluation — rather than operator precedence. So I dunno, maybe we could title the page “Operator precedence and order of evaluation” — which is somewhat ambiguous because it can be misread as being about operator order of evaluation, rather than “operator precedence” and “order of evaluation” being separate things (and I hope we have agreement that in general in languages they are two separate things…). But anyway, I don’t have a suggestion for how to make it both unambiguous and reasonably short. |
I dunno either, to be honest... Originally I thought we should remove "assignment" as well since those don't really have the idea of "precedence" (they can't associate arbitrary expressions on LHS and RHS). But if we keep removing operators (/ constructs) we just make the page less useful without any gain of utility. Maybe we can make an additional section about how the non-operator constructs compare in binding tightness with those that are operators. |
I mentioned this last year in #5365, and I’ve meant to open a pull request about this for a long time. (I think we’ve talked about it sometimes on the TC39 Matrix. I’ll try to find logs when I can.) Anyways, my opinion remains the same:
Compare I think it’s completely appropriate to include (As an aside, one might say that it’s a misnomer to call * Of course, there is one important difference: unlike [Edit: Pasting here a response to a point from @sideshowbarker on Matrix that we could exclude both It would certainly would be consistent to exclude both I think that you could rigorously define a JavaScript operator as a “syntactic token(s) that create an expression but which is not an atomic literal”, where an “expression” is a “syntax phrase that evaluates into a value at runtime”. So In contrast, the (See also prior TC39 discussion sparked by the |
I agree with the point here. At some point when I was trying to rephrase that page, I was tempted to define operators as "joiner of arbitrary expressions", in which case neither |
MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
What information was incorrect, unhelpful, or incomplete?
Maybe worth adding
=>
operator precedence? It seems to be 2 - assignment group. TC39 members often use that precedence as argument.MDN Content page report details
en-us/web/javascript/reference/operators/operator_precedence
The text was updated successfully, but these errors were encountered: