Skip to content

[ExpressionLanguage] Add operators precedence documentation #19860

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

Merged
merged 1 commit into from
May 13, 2024
Merged

[ExpressionLanguage] Add operators precedence documentation #19860

merged 1 commit into from
May 13, 2024

Conversation

homersimpsons
Copy link
Contributor

Closes #19803

@carsonbot carsonbot added this to the 7.1 milestone May 3, 2024
@homersimpsons
Copy link
Contributor Author

I'm not sure that such a big table is best. I can spread it over 2 columns, or maybe even group all operators that have the same precedence.

Also I think I should split between unary and binary operators.

@homersimpsons
Copy link
Contributor Author

I'm not sure that such a big table is best. I can spread it over 2 columns, or maybe even group all operators that have the same precedence.

So I grouped operators by precedence in a second commit.

@carsonbot carsonbot changed the title Add operators precedence documentation [ExpressionLanguage] Add operators precedence documentation May 5, 2024
@javiereguiluz
Copy link
Member

@homersimpsons thanks for this. I think it's a good idea to display this information.

However, I'm not entirely convinced by these two separate tables. I looked into how other languages solve this:

All of them use a single table and some of these also display the associativity of the operator.

So, maybe we can do this:

  • Only show one table
  • Don't show the actual numeric value of the precedence
  • List operators in rows, from most to least precedence
  • Also show the associativity ?

@homersimpsons
Copy link
Contributor Author

  • Only show one table
  • Don't show the actual numeric value of the precedence
  • List operators in rows, from most to least precedence
  • Also show the associativity

@javiereguiluz I just did the changes

@javiereguiluz javiereguiluz changed the base branch from 7.1 to 6.4 May 13, 2024 12:40
@javiereguiluz javiereguiluz merged commit bf445b1 into symfony:6.4 May 13, 2024
3 checks passed
@javiereguiluz
Copy link
Member

@homersimpsons this is now merged. Thanks a lot for contributing this.

While merging I tweaked this a bit (see c883a11) to:

  • Add a very short introduction explaining what is "operator precedence"
  • Adding a comment in the table to explain that the first - and + are the unary operators and not the addition/subtraction operators

@homersimpsons homersimpsons deleted the patch-2 branch May 16, 2024 13:18
@homersimpsons
Copy link
Contributor Author

@javiereguiluz

The rendering is not the one I was expecting, I was expecting to see all of those in only 1 cell and not in different cells.

==, ===, !=, !==, <, >, >=, <=, not in, in, contains, starts with, ends with, matches

precendence table

It worked correctly when I tested it in the codespace with the docs builder.

I'm not familiar with rst nor with Symfony rendering of this. Do you have any advice?

Note that I separated them in multiple rows so it wouldn't take too much width. And this grouping was the most logical. But they all share the same associativity and precedence.

@javiereguiluz
Copy link
Member

I recently had the same issue 😊 See #19892

The solution is to add a trailing \ to the lines that should be part of the same cell

@homersimpsons
Copy link
Contributor Author

I recently had the same issue 😊 See #19892

The solution is to add a trailing \ to the lines that should be part of the same cell

@javiereguiluz I opened #19894 for this

OskarStark added a commit that referenced this pull request May 21, 2024
…impsons)

This PR was merged into the 6.4 branch.

Discussion
----------

fix expression language precedence cell grouping

Fix for #19860 (comment)

I do not know how to test the changes as those were working with the doc builder previously.

Commits
-------

46562c0 fix expression language precedence cell grouping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ExpressionLanguage] Document precedence
4 participants