String interpolation, after a healthy debate on discord

rikki cattermole rikki at
Tue Dec 14 14:01:56 UTC 2021

On 10/12/2021 10:06 AM, WebFreak001 wrote:
> What do you think? Would this be essential for interpolated string 
> adoption in user code or be useless?

I am against it.

Due to it marrying a memory management+formatting strategy to the language.

One way to do this is to support ``Identifier Token`` UFCS pattern which 
would allow this to "just work" except generically.

So if you want to get data from your database?

auto data = dbcon.sql`SELECT * FROM table where field = "%value$arg"`;

That could pass it in as an interpolated string.

However, that could be extremely confusing to the user as this is a 
function call, which takes a string... yet its actually something very 
different. Like why doesn't adding the brackets allow for that to work? 
ext. ext.

One reason I would like this pattern even though I don't think we should 
ever have it is so that I can have hex strings back. Super useful during 
code generation and table generation for large data sets (now days I've 
found that std.base64 does an excellent job at this, even with a little 
bit of fluff).

ubyte[] data = hex"AABBCC"; // ok

More information about the Digitalmars-d mailing list