Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Steven Schveighoffer
schveiguy at gmail.com
Sun Jan 31 16:11:58 UTC 2021
On 1/31/21 10:54 AM, Andrei Alexandrescu wrote:
>> Try to please everybody and you end up pleasing nobody.
> ...
>> DIP1027 works with writef, and I consider that to be the goal, not
>> printf.
>
> Unpopular opinion follows (at this point I have no idea which side of
> the debate this puts me on).
I don't think it's unpopular, or wrong. I 100% agree with your assessment.
> But wait! one might say in response. What if I need on occasion some
> special formatting of one argument in one of them nice interpolated
> strings? No problem, I say. Do what Perl, PHP, and Python programmers
> have done for millenia - apply the formatting function separately for
> the desired argument:
>
> i"Hello, ${format(`%45s`, var)} world"!
This is how I would do it:
i"Hello, ${var.withFormat!"%45s"} world";
(where withFormat provides a toString overload that works with idup). No
extra intermediate allocations necessary.
-Steve
More information about the Digitalmars-d
mailing list