<div dir="ltr"><div dir="ltr"><div>Replying only to amber-dev for now...</div><div><br></div><div>I agree this seems like it would be an improvement. A slight variant of the problem that I've witnessed cause confusion multiple times is this (boiled down):<br></div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">public class MyClass<T> {<br> public <T> void foo() {</span></div><div style="margin-left:40px"><span style="font-family:monospace"> // easy to confuse what "T" means here<br></span></div><div style="margin-left:40px"><span style="font-family:monospace"> }<br>}</span></div><div><br></div><div>Java's decision to make the shadowing of normal variables illegal was a nice "advance" at the time, and I've always wondered why it shouldn't carry over to generic type variables as well. It seems like the same basic principle would apply.</div><div><br></div><div>Or maybe not?</div><div><br></div><div>Generic type variables are a kind of combination of "type name" and "variable". While Java doesn't allow shadowing for variables, it does for type names - for example:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">public class MyClass<T> {<br> public class String { // no error here<br> }<br> public class T { // no error here<br> }<br>}</span><br></div><div><br></div><div>So maybe Java was just making the conservative choice at the time.<br></div><div><br></div><div>-Archie<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2024 at 10:33 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com">davidalayachew@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">In the vein of smoothing the on-ramp for beginners, one of the biggest pain points I have found when tutoring beginners is when they start to learn generics, and then do something like this.</div>
</blockquote></div><br clear="all"><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>