My two cents

Martin Nowak code at dawg.eu
Mon Oct 23 11:36:31 UTC 2017


On Monday, 23 October 2017 at 09:13:45 UTC, Satoshi wrote:
> On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:
>> Hi,
>> I had been using D for almost 6 years and I want to share my 
>> opinion with you.
>> I don't want to blame anyone but I'll focus more on bad things 
>> and possible improvements.
>> And this is just how I see D from my perspective.
>> (Sorry for my English, I'm too lazy to take the lessons).
>>
>> [...]
>
> Whats about this one?
>
> auto foo = 42;
> auto bar = "bar";
> writeln(`Foo is {foo} and bar is {bar}`);

String interpolation could be done in a library.

     fmt!("Foo is ${foo} and bar is ${bar}", foo, bar)

At the moment you'd just use format.

     format!"Foo is %1$s and bar is %2$s"(foo, bar);

While both are a bit more verbose, it seems to me that 
interpolated strings aren't that big a deal.
Collecting arguments and design ideas in a DIP would still be 
worthwhile and very welcome.
Even if ends up not being approved, it would ensure a good 
decision base and avoid future discussions.

Sth. like

   s"Foo is ${foo} and bar is ${bar ~ `bla`}"

to be lowered to

  format!"Foo is %1$s and bar is %2$s"(foo, bar ~ `bla`).

could be a feasible approach on a first thought.


More information about the Digitalmars-d mailing list