Denis Derman <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #3 from Denis Derman <> 2011-02-28 05:45:19 PST 
(In reply to comment #0)
> In some situations the format string of writef/writefln is not known at
> compile-time, but it most situations it is. So in the frequent cases where the
> format string is known at compile-time I'd like an error at compile-time if 
> the
> type in the format string and the type of the arguments don't match. 
> An error at compile-time is better, it gives the same advantages of static
> typing, and it allows the programmer to catch format string bugs before
> runtime, in all the program, even in parts of the code that aren't run yet (a
> runtime bugs happens only with a specific writefln comes into the thread of
> code being run).
> Currently (dmd v2.047) this compiles with no errors:
> import std.stdio: writefln;
> void main() {
>     float f = 10.5;
>     writefln("%d", f);
> }
> But I'd like an error similar to:
> test.d(4): Error: writefln format string type error, used format '%d' but
> argument 'f' is of type float
> Once written, this new testing routine can be useful for other functions too,
> for the format(), some I/O functions, and for C functions like printf() too
> that sometimes are present in D programs.

Most commonly, format string static checking would catch arg count mismatch at

    writefln("%s --> %s", a);

compiles and builds happily; and launches at runtime:
    std.format.FormatError: std.format Orphan format specifier: %%s --> %s
(Weird error message, in fact.)


Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to