<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>1. If your class doesn't do Identity Things, make it a
value class. The VM can do smarter things now.<br>
</div>
</div>
</div>
</blockquote>
<br>
Which also makes your class safer too! <br>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>2. `==` isn't really an Identity Thing: it will just
continue to mean "observably identical*" as it always has.
System.hashCode() remains defined in terms of `==`. But
actual identity dependence will fail (when feasible, at
compile time).</div>
</div>
</div>
</blockquote>
<br>
Some readers might retort that the cost of this is `==` went from
ultra-super-cheap to maybe-but-who-knows. We might counter-retort
that such micro-performance concerns are usually a distraction. <br>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>3. Any type based on that class can be marked as nullable
`?` or non-null `!`. Conceptually (if not literally), `Foo!`
is a subtype of `Foo?`.</div>
</div>
</div>
</blockquote>
<br>
Where by "conceptually" you are appealing to "is-a". <br>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>4. Nullness enforcement is "best-effort" and better than
nothing. *If* you want the gory details of what's enforced
you can dig into them. There's still room for third-party
nullness analysis tools to help.<br>
</div>
<div><br>
<div>5. If a value class has a do-nothing constructor, and
you're fine with non-null variables of that type being
initialized to that value, add `implicit` to the
constructor. The VM can do more smarter things now.<br>
</div>
<div><br>
</div>
6. Consider adding `non-atomic` to the class; the VM can do
even morer smarter things now. The downside is that racy
code (already risky) might fail in worse ways; you decide if
that worries you or not.<br>
</div>
</div>
</div>
</blockquote>
<br>
And specifically, if your class has cross-field invariants, it
should worry you.<br>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>7. The above holds for the 8 primitive types too; yes,
they are still special, but mostly in <i>additional</i> ways,
rather than exceptions to the usual rules. `int` and
`Integer!` are now nearly synonymous.<br>
<br>
And we can finally all retire the term "primitive class" now
at last. :-)</div>
</div>
</div>
</blockquote>
<br>
Praise be.<br>
<br>
<blockquote type="cite" cite="mid:CAGKkBkv68++gOkBow4wn2Rv=LXF3b0aWBQ3GoGG=N17wj557EA@mail.gmail.com">
<div dir="ltr">
<div>
<div>
<div>While that list is meant to have asterisks and just be
"good enough for most people most of the time", it might
need some important corrections nevertheless, so, I'm glad
to hear them.</div>
<div><br>
</div>
<div><br>
</div>
<div>* yes float/double are weird</div>
<div><br>
</div>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin
Bourrillion |</span><span style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Java/Kotlin
Ecosystem Team |</span><span style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px"> Google,
Inc. |</span><span style="border-width:2px
0px
0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a href="mailto:kevinb@google.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">kevinb@google.com</a></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>