Bug 20541 – Digit separator in range format doesn't work
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-28T08:53:05Z
Last change time
2021-03-27T19:23:32Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2020-01-28T08:53:05Z
import std.stdio;
writefln("%,?d", '_', 10000); // A
writefln("%(%,?d%)", [10000]); // B
writefln("%(%,?d%)", '_', [10000]); // C
writefln("%,?d", 10000); // D
On my machine, A prints '10_000', B prints '10,000', C throws 'incompatible format character for integral argument', and D throws 'separator character expected'.
As I have specified in the element format string in B and C, I wish to pass the digit separator as an argument to writefln, but that does not appear possible. Not only that, but D throws, while B doesn't.
Solving this in a way that allows the programmer to pass the digit separator as an argument will require lookahead - the range format specifier will need to know how many arguments the element format specifier expects, and pass it those arguments. If this is not possible, the function should throw on an invalid format specifier as in case D.
Comment #1 by bugzilla — 2021-03-27T19:23:32Z
*** This issue has been marked as a duplicate of issue 18599 ***