Drop 'strong discouragement' of nested block-local variables - #34
Open
leiflindholm wants to merge 1 commit into
Open
Drop 'strong discouragement' of nested block-local variables#34leiflindholm wants to merge 1 commit into
leiflindholm wants to merge 1 commit into
Conversation
leiflindholm
requested review from
ardbiesheuvel,
makubacki and
mdkinney
as code owners
June 25, 2026 10:21
ardbiesheuvel
approved these changes
Jun 25, 2026
The rules explicitly permit variable definitions such as
if (Condition) {
UINTN Example;
...
}
But for some reason it simultaneously "strongly discourages" from it.
This feels entirely wrong to me; the codebase suffers from too-long
functions with too many live variables making compilers' work more
difficult - preventing optimisations and periodically throwing up
warnings/errors as compilers change.
Change the strong discouragement to a note on not confusing variable
scope.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
leiflindholm
force-pushed
the
block-scope-vars
branch
from
June 25, 2026 11:37
07d23cc to
787e62b
Compare
Contributor
|
I think there would a couple reasons for this restriction. The change needs to describe what has changed since the rules were established to justify the change.
|
Contributor
|
@ajfish Please provide background for original rules for local variable declarations. |
makubacki
approved these changes
Jun 25, 2026
makubacki
left a comment
Contributor
There was a problem hiding this comment.
Pending any empirical concerns, I favor this change and the file content update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rules explicitly permit variable definitions such as
if (Condition) {
UINTN Example;
...
}
But for some reason it simultaneously "strongly discourages" from it. This feels entirely wrong to me; the codebase suffers from too-long functions with too many live variables making compilers' work more difficult - preventing optimisations and periodically throwing up warnings/errors as compilers change.
Change the strong discouragement to a note on not confusing variable scope.