<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
On Mar 19, 2024, at 10:23 AM, Brian Goetz <brian.goetz@oracle.com> wrote:<br>
<div>
<blockquote type="cite"><br class="Apple-interchange-newline">
<div>
<div><font size="4" face="monospace">Let's pull on this string some more. Assuming we settled on disjoint types and syntaxes, with no magic conversions, what library support do we need directly for ST? I am thinking (please, let's focus on the functionality
before we nitpick the names): <br>
<br>
// on String<br>
static join(StringTemplate) // previously STR<br>
</font></div>
</div>
</blockquote>
<div><br>
</div>
I assume the return type for the preceding method should be `String`.</div>
<div><br>
<blockquote type="cite">
<div>
<div><font size="4" face="monospace"> // on StringTemplate<br>
String join() // STR, instance/suffix version<br>
static StringTemplate join(StringTemplate...) // + for string templates<br>
<br>
This is a pleasantly short set; is anything missing? (Not addressing the "which things were previously processors, but now need API points" right now -- that's a separate discussion.)<br>
</font></div>
</div>
</blockquote>
<br>
</div>
<div>Actually, Brian, I _am_ going to nitpick your use of the name “join” here for all three of those methods, because, given the comments, they do very different things; the first two do “string interpolation” on a single template (and in the process convert
the values in the template to strings) whereas the last combines multiple templates into a single template (but does not convert any of the values to strings).</div>
<div><br>
</div>
<div>Moreover, the existing `join` method of String does yet a different operation: concatenate a sequence of strings, using a given delimiter string (repeatedly, if necessary) as a separator. So I think “join” was a particularly infelicitous choice of name
for these three examples.</div>
<div><br>
</div>
<div>Here I set forth your three examples with new names that are related to those already used in the existing preview implementation of StringTemplate in JDK 21 (and JDK 22—I just checked). I do this not to suggest that these other names should be used, but
only in the hopes of reducing confusion as we begin this discussion. Later we can decide whether the names “process” and “interpolate” and “combine” should be changed (possibly all into the same single name).</div>
<div><br>
</div>
<div>
<div><font size="4" face="monospace"> // on String<br>
static String process(StringTemplate) // previously STR<br>
<br>
// on StringTemplate<br>
String interpolate() // STR, instance/suffix version<br>
static StringTemplate combine(StringTemplate...) // + for string templates<br>
<br>
</font></div>
<div>—Guy</div>
<div><br>
</div>
</div>
</body>
</html>