DIP 1027---String Interpolation---Format Assessment

Walter Bright newshound2 at digitalmars.com
Thu Feb 27 09:30:30 UTC 2020

On 2/27/2020 12:27 AM, Petar Kirov [ZombineDev] wrote:
> I'm well aware that allocation is inevitable if we want this behavior. My 
> argument is that this behavior is so ubiquitous that not following it would be 
> surprising to much more people, than if D didn't follow C's Usual Arithmetic 
> Conversions rules. For example, Rust not following those conversion rules is 
> considered a good thing,

Rust does not follow C syntax at all, so nobody will reasonably expect it to 
have C semantics. D does follow it, it's a feature, so people will have 

> while if D decided to be different than all other 
> languages w.r.t. string interpolation,

You can make it behave like all those other languages simply with:

     f(format("hello $a"));

and there it is. But having it generate a GC allocated string is not so easy to 
unwind, i.e. it'll be useless with printf and generate unacceptable garbage with 
writefln. The extra string will always make it slow. Essentially, it'll be 
crippled. Making D behave like a scripting language will yield scripting 

D is a language built up from simple, orthogonal parts (or at least that is a 
goal). A language built from larger indivisible parts is much, much less 
user-adaptable. An example of this is the built-in associative array, which has 
a series of fairly intractable problems as a result. Another example is the 
built-in complex type in D, which turned out to be a bad idea - a much better 
one is building it as a library type.

More information about the Digitalmars-d-announce mailing list