<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Tagir,</div>
<div class=""><br class="">
</div>
<div class="">I’ve added RAW as a standard template processor. It is not statically imported automatically (<font face="Consolas" class=""><span style="font-style: normal;" class="">import static java.lang.template.StringTemplate.RAW;
</span></font>required). I would recommend that “on inspection” giving the user the choice of;</div>
<div class=""><br class="">
</div>
<div class="">1.<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><font face="Consolas" class=""><span style="font-style: normal;" class="">STR."..."</span></font><br class="">
2.<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><font face="Consolas" class=""><span style="font-style: normal;" class="">RAW."..."</span></font><br class="">
3.<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>//noinspection IntentionalRawStringTemplate (or somesuch)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><font face="Consolas" class=""><span style="font-style: normal;" class="">"..."</span></font><br class="">
<br class="">
</div>
<div class="">
<div class="">The intention of the statement below is clear. Would inspection ignore this case?</div>
</div>
<div class=""><br class="">
</div>
<div class=""><font face="Consolas" class="">    StringTemplate st = "...";</font></div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class=""><br class="">
</div>
<div class="">— Jim</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Oct 21, 2022, at 6:17 PM, Jim Laskey <<a href="mailto:james.laskey@oracle.com" class="">james.laskey@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="auto" class="">I suppose I should have mentioned you can do this by convention as well. Define RAW and use to highlight where StringTemplates are needed. 
<div class=""><br class="">
</div>
<div class="">TemplateProcessor<<span style="caret-color: rgb(0, 0, 0);" class="">StringTemplate</span>> RAW = st -> st;</div>
<div class=""><span style="caret-color: rgb(0, 0, 0);" class="">StringTemplate template = RAW.”…”;</span></div>
<div class=""><br class="">
<div dir="ltr" class="">📱</div>
<div dir="ltr" class=""><br class="">
<blockquote type="cite" class="">On Oct 21, 2022, at 6:03 PM, Jim Laskey <<a href="mailto:james.laskey@oracle.com" class="">james.laskey@oracle.com</a>> wrote:<br class="">
<br class="">
</blockquote>
</div>
<blockquote type="cite" class="">
<div dir="ltr" class=""> It’s not unreasonable. In fact, the early POCs had a RAW processor. 
<div class=""><br class="">
</div>
<div class="">I would still like to see how it plays out as-is during Preview. Others might develop other opinions or ideas. </div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class=""><br class="">
</div>
<div class="">— Jim<br class="">
<div dir="ltr" class="">📱</div>
<div dir="ltr" class=""><br class="">
<blockquote type="cite" class="">On Oct 21, 2022, at 5:34 PM, Tagir Valeev <<a href="mailto:amaembo@gmail.com" class="">amaembo@gmail.com</a>> wrote:<br class="">
<br class="">
</blockquote>
</div>
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div dir="auto" class="">
<div class="">Hello!<br class="">
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Oct 21, 2022, 15:05 Victor Nazarov <<a href="mailto:asviraspossible@gmail.com" rel="noreferrer noreferrer" target="_blank" class="">asviraspossible@gmail.com</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div dir="ltr" class="gmail_attr">
<div class="">Hello!<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I think one suggestion that fixes stated problems was already proposed before and I heard no arguments against going this route</div>
<div dir="auto" class="">...</div>
</div>
<div class="gmail_quote">
<div class=""><br class="">
</div>
<div class="">One suggestion that fixes this problem is to forbid bare template strings without policy-prefixes and instead introduce some policy that returns TemplateString itself.</div>
<div class=""><br class="">
</div>
<div class="">````<br class="">
</div>
<div class="">    StringTemplate tmpl = TMPL."\{x} plus \{y} equals \{x + y}" ;</div>
<div class="">    String s1 = tmpl.apply(STR);</div>
<div class="">    String s2 = STR."\{x} plus \{y} equals \{x + y}";</div>
<div class="">    assertEquals(s1, s2);</div>
<div class="">````<br class="">
</div>
<div class=""><br class="">
</div>
In this world the following can be observed:<br class="">
<br class="">
````<br class="">
    System.out.println(STR."\{x} plus \{y} equals \{x + y}"); // Prints "10 plus 20 equals 30"<br class="">
    System.out.println(TMPL."\{x} plus \{y} equals \{x + y}"); // Prints "StringTemplate{segments = ["", " plus ", " equals "], values = [10, 20, 30]}"</div>
<div class="gmail_quote">    System.out.println("\{x} plus \{y} equals \{x + y}"); // COMPILATION ERROR: error: unrecognized escape sequence '\{', policy is required for template strings</div>
<div class="gmail_quote">````<br class="">
</div>
</div>
</blockquote>
</div>
</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">Sounds really good to me. In any case, template expression is not directly substitutable. E.g. you cannot replace</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">STR."Hello \{user}"</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">with</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">StringTemplate t = "Hello \{user}"</div>
<div dir="auto" class="">STR.t</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">Instead, you need to desugar to a method call, like STR.process(t). I think that in Java, all the expressions we had before were substitutable in this sense: you could extract them to variable, and use that variable instead. So it would
 be more consistent to avoid naming the right part of process template expression as expression itself. I would suggest the following:</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">If parser meets a dot that follows single double quote, or triple double quote, then the right part is always a string template, or a text blocks template, and the whole thing including qualifier is process template expression. Template
 may have no substitutions at all, in this case it looks exactly like string or text block, but it's a template. Template is not an expression and cannot appear in any context other than in process template expression.</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">This simplifies grammar somewhat, as we say that template without placeholders is still a template. Also, having an identity template processor, like TMPL proposed by Victor, makes it possible and consistent to instantiate the StringTemplate
 object that contains no placeholders. The cost is five characters (TMPL.) necessary for presumably rare and advanced uses of templates where one wants to store it without immediate processing.</div>
<div dir="auto" class=""><br class="">
</div>
<div dir="auto" class="">What do you think?</div>
<div dir="auto" class="">Tagir Valeev </div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>