[Issue 20541] New: Digit separator in range format doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 28 08:53:05 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20541

          Issue ID: 20541
           Summary: Digit separator in range format doesn't work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: simen.kjaras at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list