2 ms·
D supports calling C functions directly, including printf. When we added printf format checking against the arguments, many bugs were exposed and fixed. It was
by WalterBright 5y ago
D supports calling C functions directly, including printf. When we added printf format checking against the arguments, many bugs were exposed and fixed. It was a big win.
- kazinator 5y agoGCC has this also; this work is different because it removes the type errors. Instead of having an error like "%d expects a parameter of type int, not char ", it just lets %d print the string anyway. It's more like format* in Lisp, say: [1]> (format t "~05,'0d" 5) 00005 NIL [2]> (format t "~05,'0d" "abc") 00abc NIL Here ~d (decimal) doesn't care that it didn't get an integer.
- WalterBright 5y agoFor D's formatted write function, %s means "I don't care what type it is, just do the write thing with it" which works fine for nearly all uses.