<div dir="ltr"><div dir="ltr">Em sex., 19 de jan. de 2024 às 14:53, - <<a href="mailto:liangchenblue@gmail.com">liangchenblue@gmail.com</a>> escreveu:<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 19, 2024 at 10:07 AM John Bossons <<a href="mailto:jbossons@gmail.com" target="_blank">jbossons@gmail.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"><div dir="ltr">Thanks for your comments. I was not sufficiently explicit.<br><br>Let me focus on implicit. I guess my dislike is of introducing a 'fake' constructor into the definition of a class. I say 'fake' because, as I understand it, the only purpose of the implicit constructor is to indicate to the JVM/compiler that a never-null instance can be created. But in Java idiom that means that a developer can invoke the public implicit constructor, which will cause confusion.<br></div></blockquote><div></div></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>It is a real constructor like that default no-arg one generated by javac, and developers always CAN invoke that constructor. It is, however, a watered-down version, because our existing default one can perform side effects like `private List<Integer> values = new ArrayList<>();` injected to the end of constructor, while the implicit one must give it up so that JVM can construct zero instances cheaply yet correctly. As a result, this constructor cannot declare any side-effect code or declare a custom superconstrctor call, so it will look like a "fake" one, yet it is no different from a true constructor.</div></div></div></blockquote><div><br></div><div>C++ has the following notation for a compiler-generated "default" constructor. </div><div>It has been in place for some years and has been well received.</div><div>The meaning of the existing C++ "default" and the meaning of the proposed Java "implicit" is very similar.</div><div>I am not aware of the meaning of "default" being particularly difficult to teach.</div><div><br></div><div><font face="monospace">class foo</font></div><div><font face="monospace">{</font></div><div><font face="monospace">   foo () = default;</font></div><div><font face="monospace">}; </font></div></div><span class="gmail_signature_prefix"><div><span class="gmail_signature_prefix"><br></span></div>-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>