dart-lang / site-www

Source for Dart website
https://dart.dev
Other
968 stars 695 forks source link

Operator precedence table #4287

Closed atoka93 closed 1 year ago

atoka93 commented 2 years ago

What information is missing?

I would expect that when I search for the phrase dart operator precedence on Google to receive a first page result for the dart operator precedence table pointing to a dart.dev page.

Currently the latest operator precedence table is only accessible by tapping on the link in the following warning in the Language Tour:

Screen Shot 2022-10-15 at 2 44 57 PM

or going to the Language / Specification and opening the formal specification PDF and searching in there for the table (located on page 240 in the latest published version).

It is fairly easy to miss and can be quite helpful to have. I noticed that the operator table has the same order in the Language Tour as in the precedence table, but has the warning instead of displaying the order explicitly, not sure why.

How would you like us to fix this problem?

I would love to see the operator precedence table displayed on the dart.dev website directly so it can be indexed. One can always find the information quickly by doing the search, it is available here: https://www.woolha.com/articles/dart-operator-precedence-and-associativity ; but I think the community would have much more confidence in the validity if it would come from the official source.

parlough commented 2 years ago

Thanks for opening an issue! As you mentioned, the operator table is already present on the site, but we could be more clear it roughly represents the precedence (or can be used as a helpful guide) to make it more searchable and perhaps add associativity guidelines.

The reason we have the warning and link to the spec is not because of the table in the spec, but because the table can only be used as a guideline, as it is "not normative, and parsing questions should be resolved by consulting the grammar rules". Without this warning, people took the table as normative and definite in the past, causing confusion. Perhaps we can modify the warning or its wording in some way to make it less concerning, but it seems like it needs to remain in some fashion.

atoka93 commented 2 years ago

Thank you for the response!

we could be more clear it roughly represents the precedence (or can be used as a helpful guide) to make it more searchable

That would be helpful! 😃

I am unsure what not normative means in this context. Does it mean that there are special cases where the precedence of the operators wouldn't be as described in this table? or does it mean that it is not exhaustive? maybe both? 🤔

parlough commented 2 years ago

Ah, sorry I was just using the wording from the spec there, but yeah it essentially means that there are special cases and differences which cannot be accounted for in the table.

I'll prepare a change which makes it more clear it can be used as a helpful guide for precedence as well as modify the wording of the wording to be more around special cases to make it more clear and less concerning.

atoka93 commented 2 years ago

Thank you! 😃