Feedback Thread: DIP 1036--Formatted String Tuple Literals--Community Review Round 1
Alex Dovhal
alex.y.dovhal at gmail.com
Sat Sep 12 08:02:52 UTC 2020
On Wednesday, 9 September 2020 at 19:48:44 UTC, Steven
Schveighoffer wrote:
>> 3) `${%d}bananas` is an awful syntax compromise as it will be
>> very unintuitive to newcomers as it's not clear what the
>> variable is.
>> For example, `${bananas:2f}` would read much better. In
>> general, I like the way Python handles the format specifiers:
>>
>> https://www.python.org/dev/peps/pep-0498/#format-specifiers
>
> That is syntactically a problem. Remember that any expression
> can be the Argument to the string interpolation parameter. A
> colon followed by 2f could be valid syntax at the end of an
> expression.
>
> ${cond ? 1f:2f}
>
> If there are unambiguous alternatives that would be more
> acceptable to the language maintainers, we are fine with it, as
> long as the format string resolves in the way specified with
> the DIP. Note that this syntax comes directly from DIP1027.
How about ${expr; %2f} or ${expr, %2f} ?
More information about the Digitalmars-d
mailing list