String plus isn’t needed. Just as templates remove the need for string plus, 
the combining of string templates and strings can be done with nested embedded 
expressions.
📱

> On Mar 11, 2024, at 5:25 PM, Alex Buckley <[email protected]> wrote:
> 
> On 3/11/2024 10:36 AM, Brian Goetz wrote:
>> Overall, though, I am not so enthused about creating yet another new lexical 
>> mechanism for having different kinds of stringy things.
> All strings -- not just string literals, and not just constant expressions of 
> type String -- can be composed with +. Is there an equivalent composition 
> operator for string templates? (That is, all values of type StringTemplate, 
> not just template literals.)
> 
> I ask because the more lexical similarity between a template literal and a 
> string literal, the more I think people will try to use + with two template 
> literals, or with one template literal and one string literal. AIUI the 
> result will be a surprise:
> 
> String s = "Hello" + "\{x}";
>  // Second operand to + undergoes string conversion a.k.a. toString()
> print(s);  // Hello0x12345678
> 
> Alex

Reply via email to