<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 22, 2024 at 11:37 AM 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"><div dir="ltr"><br></div><div class="gmail_quote"><div>This made me realize this issue really is all just about naming. For example, outer instances are captured just like variables, but we don't have a problem there because the captured version of the variable has a different name inside the nested class vs. outside (i.e., "Outer.this" vs. "outer", if you create the nested class via "outer.new Inner()").</div><div><br></div><div>So with a captured variable, we are using the same name for what are in reality two different things. But instead of saying "these are really two different things" we say "there is only one possible value this/these things could have no matter where you are and so you can just pretend there is only one thing".<br></div></div></div></div></blockquote><div><br></div><div>sounds right to me.</div><div><br></div><div><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"><div class="gmail_quote"><div>Entering personal opinion territory here... I wouldn't see such a big downside with allowing capture of any variable. Maybe that's just because I know how it really works? It's just a read-only snapshot taken at that point. Even if it were a new concept, that's just not a hard concept to grasp... especially in light of the many trickier Java topics like superclass constructors invoking subclass methods, mutual recursion between class initializers, anything to do with multi-threaded code...<br></div></div></div></div></blockquote><div><br></div><div>I suspect it is specifically the fact that you can reference a field without `this.` and it really captures `this` that creates the problem here. Users would be regularly surprised that fields and locals don't work the same as each other.</div><div><br></div><div><br></div></div></div>