<div dir="ltr"><div dir="ltr">On Tue, Mar 12, 2024 at 12:08 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com" target="_blank">brian.goetz@oracle.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<font size="4" face="monospace">Have I covered the concerns raised so far?<br></font></div></blockquote><br></div><div class="gmail_quote">Thanks for the helpful discussion check-point.<br> <br>This thread has touched on a lot of different bits so for a moment I want to focus on one narrow question. Forget for a moment all the stuff about method resolution, varargs, and whether String <: StringTemplate.<br><br>I was intrigued by this comment (Maurizio):<br><br>> Another, simpler, option we considered was to use some kind of prefix to mark a string template literal (e.g. make that explicit, instead of resorting to language wizardry). That works, but has the disadvantage of breaking the spell that there is only “one string literal”, which is something we have worked quite hard to achieve.<br><br>What exactly is the advantage, in terms of the mental model of the programmer, of having "one string literal"?</div><div class="gmail_quote"><br></div><div class="gmail_quote">Maybe I'm just not seeing it.<br><br>I can understand the advantage of having String <: StringTemplate - that gives me more flexibility when passing around objects - great! But do I need that same flexibility with <i>literals</i>?<br><br>Consider how we handle float vs. double literals. They overlap for 32-bit values, which is very convenient, but you can also "force" a narrower interpretation by adding an "f" suffix. That seems like pretty much the best of both worlds to me.<br><br>So is this an analogous situation? Then we'd allow a StringTemplate literal to have an <i>optional</i> "$" prefix:<br><br><div style="margin-left:40px"><span style="font-family:monospace">obj.takingString("abcd"); // ok - string</span></div><div style="margin-left:40px"><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">Template("abcd"); // ok - template</span><br><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">StringOrTemplate($"abcd"); // ok - template</span><br><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">StringOrTemplate("abcd"); // ok - string or template (personally I don't care)</span><br><span style="font-family:monospace"></span><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">String($"abcd"); // fail</span></div><div style="margin-left:40px"><span style="font-family:monospace"></span><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">Template($"abcd"); // ok - template</span></div><div style="margin-left:40px"><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">String("x = \{var}"); // fail</span></div><div style="margin-left:40px"><span style="font-family:monospace">obj.</span><span style="font-family:monospace">taking</span><span style="font-family:monospace">Template("x = \{var}"); // ok - template</span></div><div style="margin-left:40px"><span style="font-family:monospace"></span></div></div><div><br></div><div>Thanks,<br></div><div>-Archie<br></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>