<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Brian Goetz" <brian.goetz@oracle.com><br><b>To: </b>"Remi Forax" <forax@univ-mlv.fr><br><b>Cc: </b>"Ron Pressler" <ron.pressler@oracle.com>, "Dan Heidinga" <heidinga@redhat.com>, "amber-spec-experts" <amber-spec-experts@openjdk.org><br><b>Sent: </b>Monday, February 20, 2023 9:33:34 PM<br><b>Subject: </b>Re: Implicit Record Was: JEP draft: Implicit Classes and Enhanced Main Methods (Preview)<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
<blockquote cite="mid:235253077.26502897.1676924374598.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div>
<div><br>
</div>
<div>As i said earlier, it does not work because fields and
local variables have different semantics,<br>
</div>
<div>fields are initialized with a default value while local
variables need to be initialized before use.<br>
</div>
<div>So the curtain is just a veil that will be pierced by any
students moving declarations around.</div>
</div>
</div>
</blockquote>
<br>
Of course it "works", it just might not work how you would prefer it
to.</blockquote><div><br></div><div> var greetings = 0;<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>does not work,<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> void main() {<br data-mce-bogus="1"></div><div> int greetings;<br data-mce-bogus="1"></div><div> System.out.println(greetings);<br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>does not work,<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><div> void main() {</div><div> static int greetings;</div><div> System.out.println(greetings);</div><div> }</div><div><br></div><div>does not work,</div></div><div><br data-mce-bogus="1"></div><div> void main() {<br data-mce-bogus="1"></div><div> int greetings = 0;<br data-mce-bogus="1"></div><div> for(;;) {<br data-mce-bogus="1"></div><div> int greetings = 0;<br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>does not work too.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Scope rules are different, being static is different, initialization rules are different, inference rules are different, even colors in IDEs are different.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"> <br>
<br>
Prior to learning about fields, the user can perceive local
variables (declared in a method) and "shared" variables (accessible
to all members of the class.) They can learn about their
characteristics. Then, when they learn about classes and fields and
accessibility, they can learn that the variables they were calling
"shared" are really fields. The distinction between locals and
fields is there from the beginning, though for most use cases, they
will not notice the difference. When they're ready to learn the
fine differences, there's not anything to unlearn. <br>
<br>
<blockquote cite="mid:235253077.26502897.1676924374598.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div>
<div>From my personal experience, unifying local variable and
field leads to more pain than gain, mostly because local </div>
</div>
</div>
</blockquote>
<br>
Who said anything about unification of fields and locals? Where did
you get such an idea that this is what is being proposed? </blockquote><div><br></div><div>You did, by re-using the term "variables" for both local variable and fields.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
<br>
First students will learn about statements. Then they will probably
learn about local variables. They can be taught that they disappear
when the method exits, and each invocation of the method gets a
fresh copy. Then they can learn about multiple methods, and then
that there are variables that can be shared across methods and
retain their values across method invocations, and while their
declaration syntax is the same (they're both variables, after all),
the _place_ in which they are declared is different (which is what
makes them shared), and shared variables have slightly different
characteristics (though not so different they have to learn this
immediately). They can learn the characteristics of shared
variables when it makes sense to teach this. And when the curtain
is pulled back, they learn all fields have the characteristics of
these shared variables. </blockquote><div><br></div><div>Record components behave as you said, they have slightly different characteristics than local variables and it's hard to not notice the difference syntactically.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>record Hello(String name) {<br data-mce-bogus="1"></div><div> void hello() {<br data-mce-bogus="1"></div><div> System.out.println("hello " + name);<br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> void bonjour() {<br data-mce-bogus="1"></div><div> System.out.println("bonjour " + name);<br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div>}<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Class fields are far more different than just the lifetime but have a very similar syntax.</div><div><br data-mce-bogus="1"></div><div>RĂ©mi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
<br>
<br>
<br>
<br><br></blockquote></div></div></body></html>