[OT] C# can do all the interpolated strings now

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Dec 9 11:09:00 UTC 2021


On Thursday, 9 December 2021 at 10:43:07 UTC, deadalnix wrote:
> In its current form, I'm not convinced the current proposal is 
> something we want. If this reaches any kind of scale, this will 
> inevitably end up as a forbidden language construct in a linter.

What I don't understand is why meta-programming isn't 
strengthened instead so that string interpolation can be 
implemented as a library construct. If you then put it in the 
standard library compilers can recognize it and optimize for it.

You basically need:

1. custom literals (seek inspiration in C++)
2. some limited AST rewriting capabilities.

That would also make it much easier to write DSLs.

D needs to hunker down on meta-programming and not spread itself 
thin across the feature-set of other languages.

There is also no universal syntax for interpolation that works in 
all contexts. E.g. in regexes many symbols will be confusing, in 
complicated strings with many sigils you want substitution to 
stand out (which is why Angular uses ```{{…}}```). In a DSL you 
can also have much safer and more convenient interpolation, e.g. 
a SQL DSL could check that tables exists in a model at compile 
time or something to that effect. Bring custom verification of 
string-literals by adding user defined literals instead.

D really needs to stop running after other languages and instead 
bring unique benefits to programmers, based on meta-programming.




More information about the Digitalmars-d mailing list