<div dir="ltr"><div>I've recently become aware of JEP 468, due to a post on Reddit showing off its capability, after hearing about it in recent Java talks.</div><div><br></div><div>I love it, however, I think the current syntax for invoking a with {} block inhibits readability by people, especially students of Java.</div><div><br></div><div>At the moment in the Java language, most instances of instance creation (that I'm aware of) is done using the new keyword, or factory methods that call it on your behalf.</div><div><br></div><div>I'd instead propose that derived record creation uses the keyword `new` **somewhere** in the syntax, to keep with consistency.</div><div><br></div><div>e.g. borrowing some inspiration from java's anonymous classes, the following syntax might work.</div><div><br></div><div>```</div><div>Point finalLoc = new Point with nextLoc { <br>    x *= 2; <br>    y *= 2;<br>    z *= 2;<br>};</div><div>```</div><div><br></div><div>it feels a little wordy, so I'm not sure, but it might open the door to the following future changes too, if C# style object initialization was added, </div><div><br></div><div>```</div><div><div>Point finalLoc = new Point with { <br>    x = 2; <br>    y = 2;<br>    z = 2;<br>};</div></div><div>```<br><br>The thing I fear with this, is it starts looking very similar to anonymous inner classes, if it wasn't for the with keyword and it being applied to records, so maybe there's a good reason that I'm missing that derived record creation looks succinctly different. </div><div>Ideally new class creation would look distinctly different from new instance creation, but alas, it's impossible to change the past syntax.</div><div><br></div><div>Just as food for thought, imagining using both anonymous inner classes and with's on classes, </div><div><br></div><div><div>```</div><div><div>Point finalLoc = new Point() {</div><div>  // class changes</div><div>} with nextLoc { <br>  // derived class edits<br>};</div></div><div>```<br></div></div><div><br></div><div>But this would likely be bad code anyway, due to mixed types being used with 'with' blocks, and an instance being thrown away just to create the derived class, but it's interesting to consider the syntax would be flexible enough to work like this, at least in an abstract ideation sense.</div><div><br></div><div><br></div><div>I recognize that the JEP labelled `Analogy to pattern matching`, it shows how the proposed syntax looks similar to a common switch expression idiom that people have adopted for records, which is good and all, but the switch expression uses the new keyword, making it stand out, and I wonder how widely adopted it is vs 'new'.</div><div><br></div><div>I don't want to stall the feature, but I believe that using the current syntax will impact new users in learning Java, ever so slightly.</div><div><br></div><div>Forgive me if I am out of pocket, I realize this looks a lot like classic bike-shedding but I'm relatively junior in the Java sphere, and I've seen people almost begging for newer users to provide feedback on JEPs in reddit comments instead of talking on social media.</div><div><br></div><div>--</div><div>Ryan Leach<br><div><br></div></div></div>