Notes from C++ static analysis

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Jun 26 23:45:23 PDT 2013


On 6/26/13 8:26 PM, Andrej Mitrovic wrote:
> The way I see it, write/writef is primarily used for debugging and
> benefits having some lax features, whereas format is used in more
> heavy-duty work where it's important not to screw things up at the
> call site.

Then I think all the more format should allow more arguments than format 
specifiers. That does help serious use.

> But the bottom line is I don't think we need to force anything on
> anybody. If anything, we could split up the internal format
> implementation and provide format and safeFormat functions.
>
> format("%s %s", 1);  // no exceptions

NO! This is exactly the kind of code that is buggy and useless. The 
right use cases involve more arguments than format specifiers.


Andrei


More information about the Digitalmars-d mailing list