> 1. A local variable in a function happens to have the same name as a global variable, and thus shadows the global variable.
Maybe name it something else more specific clearly indicating it is a global?
> 2. A lambda expression happens to use the same parameter name or local variable name as a variable name in the enclosing function.
It’s in the enclosing function; it’s precisely the kind of thing that invites confusion. Just name it something different?
> And I do not like the `-Wshadow` warning.
I do. It has avoided bugs in my code. It can cause problems, people created that warning for a reason.
If you say “I want this because of access control” then I get. If you say “I want this because I want to shadow variables easier” then I think that sounds like a bad idea, because I think shadowing is a bad practice.
One identifier should unequivocally refer to one object, I think it is ok to change what you can access in that object at certain times, but not change to a different object entirely. When you change the object entirely, that’s exactly where things start to get confusing, and hard to follow, and that’s where you get bugs.
From: Yongwei Wu <wuyongwei@gmail.com>
Sent: Monday, August 24, 2026 08:39
To: std-proposals@lists.isocpp.org
Cc: Tiago Freire <tmiguelf@hotmail.com>
Subject: Re: [std-proposals] Forget forget let's redact
Shadowing is not normally intentional. I agree intentional shadowing is weird, but consider the following scenarios:
1. A local variable in a function happens to have the same name as a global variable, and thus shadows the global variable.
2. A lambda expression happens to use the same parameter name or local variable name as a variable name in the enclosing function.
I would argue that renaming the inner variable due to collision with an outer variable is unnecessary. And I do not like the `-Wshadow` warning.
By the same logic, `redact` should not interfere with a variable declaration in another scope.
Except for the fact that people probably do not want a new keyword, I do not like the function form of `redact`, which is deceptive. `redact` is not a function call, but something more like a variable declaration. Following declaration rules would make it simple to understand and reason with.
By the way, I find `redact` reasonable, but cannot find a valid use for `unredact`.
On Mon, 24 Aug 2026 at 05:27, Tiago Freire via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
I personally never thought that variable shadowing was ever a good practice.
Having the same variable name serve different purposes in the same function is just asking for confusion. The feature should control access, not be an enabler for confusing code practices.