DIP 1027---String Interpolation---Community Review Round 1

Patrick Schluter Patrick.Schluter at bbox.fr
Wed Dec 11 15:41:56 UTC 2019


On Wednesday, 11 December 2019 at 10:57:13 UTC, Alexandru 
Ermicioi wrote:
> On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker 
> wrote:
>> [...]
>
> Why not just split interpolated string into just a tuple of 
> args & strings. For example:
> Given: (i"I ate %apples and %bananas totalling %(apples + 
> bananas) fruit.")
> Is lowered to a tuple: ("I ate ", apples, " and ", bananas," 
> totalling ", apples + bananas," fruit.")
>
> It seems current version unnecessarily ties to printf 
> formatting syntax, and makes harder for them to be used in 
> custom user code.
>
> Also user still needs call a function to get assembled string 
> which differs from what other languages are doing with 
> interpolated strings.
>

This wouldn't work for C formats like printf. The proposition has 
the nice property of being usable for DasBetterC and interfacing 
with C libraries that use format specifiers (libxml2 anyone?).


More information about the Digitalmars-d mailing list