<p dir="ltr">Yea, Brian, I agree with you. I wasn't even proposing that as argument against proposal, more like a nasty little detail, hence this is a "side note". Moreover, if (or, I hope, when) more record features expanded to all classes, compiler will still be required to clone non-value objects since they can be mutable, and with implies making a copy (although not always actually has to do it as in my example).</p>
<p dir="ltr">But I gave more thought to this today, and what I have concluded is that I would rather vote against it. The reason is that only value that "new" brings to the table here is better "human readability". But, for me it seems more like a mumbling. I am, I guess, more of a writablity guy than most people here, so I don't really like mumbling. Also it is some noise for reader. "New" here does not help resolve some ambiguity nor for compiler nor for reader, at least as it seems for me. That's why I would say I am not a fan of this syntax</p>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 20, 2024, 15:18 Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> Hello. Just a side note: AFAIK "new", by spec, guarantees that new <br>
> instance of object is returned<br>
><br>
<br>
Historically this is true. However, when Valhalla gives us value types, <br>
the "new"-ness of a new value object will be indistinguishable from an <br>
old object. So I would advise against taking this "new means new" <br>
dictum too literally.<br>
<br>
> , so it can potentially affect implementation requirements for <br>
> compilers, forcing them to copy records even if with expression block <br>
> is empty, i.e.<br>
><br>
> var b = new a with {}<br>
><br>
> Unless there is a exception for such syntax, new will mandate that b <br>
> != a (by reference)<br>
><br>
<br>
... unless a and b are value objects, in which case == compares their <br>
state, not their identity (because they have none.)<br>
<br>
<br>
</blockquote></div>