DIP 1027---String Interpolation---Community Review Round 1
Paul Backus
snarwin at gmail.com
Thu Dec 12 07:11:00 UTC 2019
On Thursday, 12 December 2019 at 06:47:28 UTC, Ernesto
Castellotti wrote:
> On Wednesday, 11 December 2019 at 20:46:03 UTC, Meta wrote:
>> Really, though, all that's needed is to allow mixin templates
>> to be mixed in without using the `mixin` keyword (I say "all",
>> but that's quite a large language change):
>>
>> string interp(string s)()
>> {
>> ....
>> }
>>
>> mixin template i(string s)
>> {
>> enum i = mixin(interp!s);
>> }
>>
>> auto n = 2, m = 5;
>> auto s = i!"The product of ${n} and ${m} is ${n * m}";
>> writefln(s);
>
> This would be really cool
One idea I've seen floated in a previous thread is to introduce a
new unary operator that could take the place of the "mixin"
keyword. So instead of
auto s = mixin(interp!"My ${vehicle} is full of
${creature}s!");
you could instead write something like this:
auto s = @interp!"My ${vehicle} is full of ${creature}s!";
More information about the Digitalmars-d
mailing list