<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Brian Goetz" <brian.goetz@oracle.com><br><b>To: </b>"Duncan MacGregor" <duncan.macgregor@servicenow.com>, "amber-dev" <amber-dev@openjdk.java.net><br><b>Sent: </b>Monday, April 3, 2023 2:33:58 PM<br><b>Subject: </b>Re: Feedback: String Templates (JEP 430)<br></blockquote></div><div><style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}div.WordSection1
{page:WordSection1;}</style></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><font size="4"><font face="monospace">If you pull on this string a
little more, you realize there is very little string left before
you get to the knot labeled "compiler plugins". In order to get
compile-time type checking for arbitrary template processors,
the template processor class must be available at compile time,
and the compiler must be willing to invoke it during
compilation. While I realize there are lots of folks who think
that would be a great thing, that's pretty far from the goal of
this work. <br><br>
For processors like FMT, since they are specified in the JDK,
IDEs can do much of the work here, and it is conceivable `javac`
can have lint warnings that understand the format specifier. <br><br>
For arbitrary processors, annotation processors can add
additional ad-hoc type checking.</font></font></blockquote><div><br></div><div>The typechecking + call invokedynamic can also be implemented as a Leyden Condenser (once we have them).<br data-mce-bogus="1"></div><div>In that case, the typechecking is delayed until the image creation.</div><div><br data-mce-bogus="1"></div><div>I believe that if the template processor is implemented using a lazy static final [1] (so it's initialization does not depend of the execution of the static block), we can come with a condenser generic enough to work with all template processors.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>regards,<br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>[1] https://bugs.openjdk.org/browse/JDK-8209964<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><font size="4"><font face="monospace"><br></font></font><br>
<div class="moz-cite-prefix">On 4/3/2023 6:41 AM, Duncan MacGregor
wrote:<br>
</div>
<blockquote cite="mid:MW5PR08MB821347E04688C2CC0C17B63AE6929@MW5PR08MB8213.namprd08.prod.outlook.com">
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">While I agree that compile time
type checking and constants are a separate topic, string
templates, and especially the template formatter, seem like
a reasonable entry point to think about them as they rely on
a new bit of syntax and are being compiled to something
special (an invoke dynamic based callsite whose bootstrap
takes the fragments and the method type). The problem I see
at the moment is that it’s not clear to me that the type
information remains available to the processor in a way that
would make for compile time type checking to be added later,
and it would be a shame if we cut this path off now. The
ProcessorLinkage interface feels like it might be closer to
path allowing this, but I see that it’s sealed at the
moment.</span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">It would be sad if we can’t
leverage a new way of string formatting to introduce compile
time type checking of those format strings when it feels
like we’re really close to being on a path that would enable
it in a natural way.</span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">Duncan.</span></p>
</div>
</blockquote>
<br><br></blockquote></div></div></body></html>