Skip to content

Improve printing of nested expressions#5918

Merged
ChrisJefferson merged 1 commit intogap-system:masterfrom
fingolfin:mh/PrintPrecedence
Feb 13, 2025
Merged

Improve printing of nested expressions#5918
ChrisJefferson merged 1 commit intogap-system:masterfrom
fingolfin:mh/PrintPrecedence

Conversation

@fingolfin
Copy link
Member

Specifically, make it better at eliding redundant parenthesis. We do so by changing the code so that the PrintPrecedence is reset to 0 whenever a expression is print that is not a unary or binary op, and then restored afterwards. For "leave" expressions such as integer literals this has no effect. But for expression that can have further subexpressions, such as function expressions, list expression, permutation expressions etc., this allows us to avoid redundant parenthesis.

Resolves #4523 by @zickgraf

Specifically, make it better at eliding redundant parenthesis. We
do so by changing the code so that the PrintPrecedence is reset to
0 whenever a expression is print that is not a unary or binary op,
and then restored afterwards. For "leave" expressions such as
integer literals this has no effect. But for expression that can
have further subexpressions, such as function expressions, list
expression, permutation expressions etc., this allows us to avoid
redundant parenthesis.
@fingolfin fingolfin added topic: kernel release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels Jan 27, 2025
@fingolfin
Copy link
Member Author

Any thoughts on this @ChrisJefferson ?

@ChrisJefferson
Copy link
Contributor

I had a good poke, just to check I couldn't find any issues with this, but it all seems good.

@ChrisJefferson ChrisJefferson merged commit 222f357 into gap-system:master Feb 13, 2025
31 of 33 checks passed
@fingolfin fingolfin deleted the mh/PrintPrecedence branch February 13, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected parentheses when displaying certain functions

2 participants