Exceptional coding style

Artur Skawina art.08.09 at gmail.com
Tue Jan 15 02:59:04 PST 2013


On 01/15/13 00:37, bearophile wrote:
> Walter Bright:
> 
>> http://kotaku.com/5975610/the-exceptional-beauty-of-doom-3s-source-code?post=56177550
> 
> From the article:
> 
>> [Side note: John Carmack has stated that static analysis tools
>> revealed that their common bug was incorrect parameter matching
>> in printf(). I wonder if they've changed to stringstreams in
>> Rage because of this. GCC and clang both find printf()
>> parameter matching errors with -Wall, so you don't need
>> expensive static analysis tools to find these errors.]
> 
> I'd like the D front-end to statically detect wrong parameter matching errors for the write*()/format() functions. (In D I don't use "%s" all the time).

Library territory. There's no need to put this in a D compiler.

Except if you'd like to have 'printf("%.2g", d)' instead of 'printf!"%.2g"(d)'
syntax.
Which could be done via a 'printf(enum string, ...);' overload [1] - still
no need for placing the format string verification logic inside the front end.

artur

[1] 'enum' is a better fit for current D, 'static' would be better if 'static'
would be defined saner. For this case the name of the storage class does not
really matter.


More information about the Digitalmars-d mailing list