DIP 1027--String Interpolation--Final Review Discussion Thread

Adam D. Ruppe destructionator at gmail.com
Wed Feb 5 22:30:14 UTC 2020


On Wednesday, 5 February 2020 at 16:37:52 UTC, Jacob Carlborg 
wrote:
> I've been thinking something similar for quite a while. Here's 
> my idea, it's a simple extension to Adam's proposal:

Anything with an @attribute makes me "bleh". I'd really rather 
just have the explicit function to build a string. The explicit 
function is not a big hassle while being more friendly to several 
other uses.

I'm not convinced that assigning to a string variable will 
actually be the most common usage though. You're surely creating 
this string to do something... and the variable doesn't actually 
do anything. You're surely going to pass it to a function 
eventually.. and often sooner rather than later.

I use `writefln` more often than `format`, for example. Most my 
cases of `"x" ~ to!string(y)` are in order to prepare a call to a 
function (actually most of those in my code are actually to make 
the `new Exception` argument - which I believe is bad code 
anyway, I'm just lazy af. I'd prolly just .idup an interpolated 
string there).

I could be wrong... but I doubt it. And the `.idup` makes it so 
simple even if it is common I doubt it will be a problem in 
practice. If we put out a beta and it was a big problem though we 
could revisit.

> Some version of "string build"? I.e. "string builder", "string 
> building" or similar.

Yeah, I am thinking the formattable tuple name or maybe "string 
builder literal" too.

did a few more minor tweaks here including the new name btw 
https://gist.github.com/adamdruppe/a58f097d974b364ae1cbc8c050dd9a3f


More information about the Digitalmars-d mailing list