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).

     // on String
     static String process(StringTemplate)    // previously STR

     // on StringTemplate
     String interpolate()                             // STR, instance/suffix 
version
     static StringTemplate combine(StringTemplate...) // + for string templates
Maybe I’m missing something, but: Why do we need both `String::process`
and `StringTemplate::interpolate`?  What are the use cases?

For a similar reason we currently have String::valueOf(int) and Integer::toString(int).  In some use cases, the "prefix" usage (static method) feels more natural, whereas in others, the "suffix" usage (instance method) feels more natural.

Even if we end up with only one, I would rather not bias towards "of course it is the static version" at this early point; I am trying to sketch out scope right now.

Reply via email to