<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">We have gone back and forth on
this, but I believe we are better served by not allowing string
templates as statement expressions. A string template is
supposed to _produce something_, not _operate by side effects_.
A statement expression serves only to normalize its use to
produce side effects. </font></font><br>
<br>
<div class="moz-cite-prefix">On 7/12/2023 7:26 AM, Bas Leijdekkers
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAC=TH2b-K4-vK9ngNkjSXyT4AK1NNKtq0kUv5wkbTev6-7eRPA@mail.gmail.com">
<div dir="ltr">Hello Amber-dev,
<div><br>
</div>
<div>In the String Templates draft specification, I don't see
any changes in JLS Chapter 14.8 Expression Statements. This
makes me think that Template Expressions are not allowed to be
used as statements. However javac in jdk21-ea accepts a
Template Expression used as a statement without reporting any
error. (I am using build 21-ea+30-2426). So it appears to me
either the specification or javac is incorrect. Which one
should I believe?</div>
<div><br>
</div>
<div>Example code:</div>
<div>```</div>
<div>class TemplateExpressionStatement {<br>
public static void main(String[] args) {<br>
STR."\{}";<br>
}<br>
}<br>
</div>
<div>```</div>
<div><br>
</div>
<div>Bas</div>
</div>
</blockquote>
<br>
</body>
</html>