From 787e62b66db624217dabdf76d8329e946acd2520 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 25 Jun 2026 11:07:17 +0100 Subject: [PATCH] Drop 'strong discouragement' of nested block-local variables 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 --- 5_source_files/54_code_file_structure.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/5_source_files/54_code_file_structure.md b/5_source_files/54_code_file_structure.md index c0eb946..cecb50b 100644 --- a/5_source_files/54_code_file_structure.md +++ b/5_source_files/54_code_file_structure.md @@ -114,8 +114,9 @@ creating a new scope. Data declarations may follow the opening brace of a compound statement, regardless of nesting depth, and before any code generating statements have -been entered. Other than at the outermost block of a function body, this type -of declaration is strongly discouraged. +been entered. This can be helpful to reduce the number of live variables at +function scope, but care should be taken that it does not make variable +scope confusing. ********** **Note:** Visual C++ gives all structure declarations File Scope, even though