<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Thanks for clarifying. That makes sense.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">In that respect, yes, I can't imagine a world where that would be legal. Java absolutely made the right choice then.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">But following your second example, I see what you mean. Still, I think that, even then, a warning should have been made. Giving users a notice that they are treading into dangerous waters is exactly the type of guard rail that helps users make more confident decisions and increase adoption.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">I say, rather late than never.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 15, 2024 at 6:01 PM Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com">archie.cobbs@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"><div dir="ltr">On Mon, Apr 15, 2024 at 4:27 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>> wrote:</div><div class="gmail_quote"><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"><div style="font-family:monospace">> Java's decision to make the shadowing of normal variables illegal...<br><br>I'm actually confused what you mean here.</div></div></blockquote><div><br></div><div>Sorry, my fault for not being clear - Java only disallows "shadowing" for variables declared in the same method, e.g., like this:</div><div><br></div><div><span style="font-family:monospace"> public void foo(int x) {<br> while (true) {<br> float x = 1; // error: variable x is already defined in method foo(int)<br> x += 7;<br> }</span></div><div><span style="font-family:monospace"> }</span><br></div></div><div><br></div><div>But it doesn't prevent variables from overshadowing fields as you point out.<br></div><div><br></div><div>-Archie</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>
</blockquote></div>