Walter Bright <> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
                 CC|                            |
         Resolution|                            |WONTFIX

--- Comment #6 from Walter Bright <> 2011-02-28 
10:14:50 PST ---
(In reply to comment #5)
> Once present this compile-time tests are applied on the format strings of
> printf and related functions too, not just for writef/writefln.

D's method of fixing printf is to use writef instead.

C's printf method has serious problems because when there is a mismatch between
the format and the args, you get garbage results at runtime and even crashes.
Hence the motivation for a format checker.

But in D, writef is typesafe. Granted, the error will get caught at runtime
rather than compile time, but it is effective. Furthermore, the incidence of
such errors is much reduced for D. For example, quick, what's the right printf
format specifier for size_t? No problem for writef, just use %s for any type.

Your argument about issuing an error when trying to use use %d for a float and
should be replaced with %f is missing the point of how writef works. With
writef, you do NOT use a format specific to the type. Just use %s. The only
time another format would even be used is if something more specific was
needed, such as rounding or x many digits past the decimal point, or printing
the value in hex notation.

In summary,

1. fixing calls to printf falls outside of the scope of D. C is C, and D
deliberately does not attempt to fix C APIs. (Part of the reason for that is
because fixing C APIs means writing all our own documentation for those APIs.)

2. the big problems printf has are simply not there with writef. The remaining
issue (compile time vs runtime error) is small enough to be not worth a
language feature customized for it

2. such a feature would lockstep the compiler to a specific library
implementation of writef, which is outside of the scope of the core language.

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

Reply via email to