<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>"Anderson Vasconcelos Pires" <andvasp@gmail.com><br><b>Cc: </b>"Remi Forax" <forax@univ-mlv.fr>, "valhalla-dev" <valhalla-dev@openjdk.java.net><br><b>Sent: </b>Wednesday, January 11, 2023 6:35:01 PM<br><b>Subject: </b>Re: Civilizer - let's civilize those primitive types !<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;">
I think you may be missing out on the goal here. This is not an exploration of the user model (value vs primitive class, val/ref/bang/etc), this is an exploration of the underlying translation / implementation scheme *that might inform* future evolution of
the user model.
</blockquote><div><br></div><div>yes,<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;"><div class=""><br class="">
<div><br class="">
<blockquote class="">
<div class="">On Jan 11, 2023, at 12:29 PM, Anderson Vasconcelos Pires <<a href="mailto:andvasp@gmail.com" class="" target="_blank">andvasp@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">Thanks for the prompt response!<br class="">
</div>
<div class="gmail_quote"><br class="">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;" class="">
<div class="">
<blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;" class="">
<div dir="ltr" class=""><span style="font-family:arial,helvetica,sans-serif;font-size:12pt" class="">Mostly prototyping a proposal to remove Q-types (descriptor that starts with Q...;) and replace them by an attribute on methods and fields indicating if the
value can be null.</span><br class="">
</div>
</blockquote>
<div class="">see <a href="https://mail.openjdk.org/pipermail/valhalla-spec-experts/2023-January/002217.html" target="_blank" class="">
https://mail.openjdk.org/pipermail/valhalla-spec-experts/2023-January/002217.html</a><br data-mce-bogus="1"></div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">So if you want to remove Q types it means that L type does not need the identity information, right? </div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Currently when you have a primitive class, you need to declare the class as a private class *and* you need to use a Q-type each time you mention that class (in a method descriptor, a field descriptor, in a checkcast, see JEP 401). <br></div><div>The idea here is when you need to declare the class as a private class but instead of using a Q-type, you use a side attribute that indicates if null is a valid value or not.<br></div><div><br data-mce-bogus="1"></div><div>To answer your question, you do not need the identity information at use site, what you need to know is if it is a zero-default value class and if null is not a valid value. Previous both information where grouped together inside the Q-type, i'm proposing to keep them into two location and let the VM gathers those information together.<br data-mce-bogus="1"></div><div><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;"><div class=""><div><blockquote class=""><div class=""><div dir="ltr" class=""><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 style="font-family: arial, helvetica, sans-serif; font-size: 12pt;" class="">
<blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;" class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
</div>
</blockquote>
<div class="">There is no notion of .val or .ref, if you want a field to be flattened, use a @Zero-Default and declare the field @NonNull.<br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Pretty good if we do not need to use .val or .ref!</div>
<div class="">
<div class=""><br class="gmail-Apple-interchange-newline">
Could the @NonNull be replaced by "!" but writing the attribute in the class file?<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I Like @NonNull but I believe the "!" would be more practical.</div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>See Brian answer,<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;"><div class=""><div><blockquote class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">
<div class=""> <br class="">
</div>
<div class="">As @Nullable is the default, maybe it would not be necessary to have it.</div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>We will need a way to say that Map<String, @NonNull Foo>.get() return type is a nullable Foo, even if the V (in Map<K,V>) is a non-null Foo.<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;"><div class=""><div><blockquote class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">
</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;" class="">
<div class="">
<blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt;" class="">
<div dir="ltr" class=""><span style="font-family:arial,helvetica,sans-serif;font-size:12pt" class="">yes, the prototype does not do any verification that the compiler does, i'm too lazy for that but the VM will catch you and throw an Error</span></div>
</blockquote>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Pretty good for a prototype! </div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;" class="">
<div class="">
<div class="">About the mutability of fields, fundamentally, value type is about saying, i give up the notion of identity, if you have no identity, you have no location in memory (you can have more than one if you prefer) so the VM is free to pass by reference
or pass by value. So you can not mutate a field, because you can only do that if you have one location in memory.<br class="">
</div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Ok for mutability but now I am a little bit confused about references, identity and memory location. </div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>You are not alone :)<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>In Java, all classes have references / instances / objects. This does not change with the introduction of value class.<br data-mce-bogus="1"></div><div>Identity class have references which have an identity, so == will compare the address in memory.<br data-mce-bogus="1"></div><div>Value class have references which does not have an identity, so == will compare the content on the object.<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;"><div class=""><div><blockquote class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">Value class is a reference type that does not have identity. So it means that it can be allocated in the heap, right? </div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>No, it means the opposite. Having an identity is equivalent to saying having an address in memory in the heap.</div><div>So having no identity means that the VM is free to chose to allocate it in the heap, to not allocate it in the heap, or even to allocate it multiple time in the heap, because from the user POV all these objects can not be distinguished one from another, thus they are one.<br></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;"><div class=""><div><blockquote class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"></div></div></div></blockquote></div></div></blockquote><div>RĂ©mi<br data-mce-bogus="1"></div><div><br></div></div></div></body></html>