Warning on template parameter identifier shadowing?
Steven Schveighoffer
schveiguy at gmail.com
Wed Aug 5 16:22:48 UTC 2020
On 8/5/20 12:10 PM, Paul Backus wrote:
> On Wednesday, 5 August 2020 at 11:12:53 UTC, Johan wrote:
>> What do you think about adding a warning about shadowing of an outer
>> template parameter by an inner template parameter name?
>>
>
> Not a fan. There are cases where I've done this intentionally--not with
> eponymous template members, but with private helper templates:
>
> template foo(T) {
> enum helper(T) = ...; // error?
> void foo(T i) {
> static if (helper!T) ...;
> else ...;
> }
> }
I've intentionally done that, and even though it worked, rewrote the
template parameter names because it's confusing to read.
It would have to be a long deprecation cycle.
I would be in favor of the change.
-Steve
More information about the Digitalmars-d
mailing list