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

Walter Bright newshound2 at digitalmars.com
Sat Dec 14 08:18:40 UTC 2019


On 12/11/2019 10:40 AM, Anonymouse wrote:
> To preempt any suggestion to just use format with %n$s positional specifiers 
> instead, I present to you non-trivial cases of Bash colour highlighting.
> 
> enum logtint = "\033[1;32m";
> enum warningtint = "\033[1;31m";
> enum resettint = "\033[0m";
> 
> writefln("%3$sException: %1$s%2$s%3$s (at %1$s%4$s%3$s:%1$s%5$d%3$s)%6$s",
>      logtint, e.msg, warningtint, e.file, e.line, resettint);

Not going to use positional specifiers:

1. I don't see much point to them
2. more complexity
3. problems with evaluating an argument multiple times when there are side effects.


More information about the Digitalmars-d mailing list