<div dir="ltr"><div>Thank you. <br></div><div><br></div><div>><font size="4" face="monospace">it's a pretty verbose
syntax<br></font></div><div><font size="4" face="monospace">Agreed. I was trying to stay close to the current syntax but even more concise could be: R r = {a: 1, b: 2}. But the question was not about the syntax.</font></div><div><font size="4" face="monospace"><br></font></div><div><font size="4" face="monospace">> </font><font size="4" face="monospace">it makes it
harder to refactor from records to classes</font></div><div><font size="4" face="monospace">Wouldn't the current JEP also have the same limitations? Although I do see the JEP mention that it may be possible in the future for regular classes.</font></div><div><font size="4" face="monospace"><br></font></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Regards<br></div><div>Swaranga</div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 29, 2024 at 3:11 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.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"><u></u>
<div>
<font size="4" face="monospace">While such a feature is possible, I
am not particularly excited about it for several reasons. If the
goal is "I want to construct using named instead of position
arguments" (which I think is your goal), it's a pretty verbose
syntax; a better one would be <br>
<br>
new R(a: 1, b: 2)<br>
<br>
But that's a much smaller concern. The bigger one is that I don't
think the language is improved by having a named parameter
mechanism for records, but for nothing else (not for instantiating
class instances, not for invoking methods.) While it might seem
"better than nothing", having two different ways to do something,
but one of them only works in narrow situations, is as likely to
be frustrating than beneficial. If the payoff is big enough, then
it might be a possibility, but "invocation by parameter name" is
nowhere near that bar. <br>
<br>
Finally, if it works for records but not for classes, it makes it
harder to refactor from records to classes, since there will be
use sites that have to be adjusted. <br>
<br>
So I think for the time being, the answer is "no", though if we
run out of things to work on, we might reconsider.<br>
<br>
</font><br>
<div>On 2/29/2024 4:34 PM, Swaranga Sarma
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>The JEP looks really promising. However I am wondering if
there will be a separate JEP for creating new records from
scratch with similar syntax.</div>
<div><br>
</div>
<div>The current JEP states that its goals are to enable
creating records from an existing record and for that it seems
sufficient. But I would also love to be able to create new
records from scratch using the same syntax. Something like:<br>
</div>
<div><br>
</div>
<div>var circle = new Circle with {</div>
<div> radius = 0.5f;</div>
<div> center = new Center with {</div>
<div> x = 0;</div>
<div> y = -1;</div>
<div> z = 8;<br>
</div>
<div> };<br>
</div>
<div>};</div>
<div><br>
</div>
<div>Originally I had asked Brian Goetz about record literals
and they seemed like a possibility but withers seem like a
more general feature so I am hoping something like this would
be supported in the future.<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>Regards<br>
</div>
<div>Swaranga Sarma<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</div>
</blockquote></div>