From: James Kanze (kanze_at_[hidden])
Date: 2002-01-27 11:59:33
Daryle Walker <darylew_at_[hidden]> writes:
|> The printf syntax explicitly mentions the type and formatting
|> options for each parameter. C++'s better type checking eliminates
|> the need for the explicit typing, and the ability to add manipulator
|> objects eliminates the need for explicit formatting.
The first isn't quite true, and won't be as long as there are implicit
conversions. Probably the most frequent error in using printf was to
pass a constant 0 to something like a "%6.2f". A C/C++ user expects
this to be allowed, since I can normally use an integral constant where
ever a floating point is needed, and a good formatting function will
know that a floating point is expected, and do the conversion.
As for the second, ask any programmer who has used both printf and
manipulators which he prefers. With regards to the i18n aspects, I'm of
two minds here, but it isn't difficult to think of cases where the width
or precision should vary according to the locale.
|> By the way, Robert's approach doesn't mention about how to write
|> brackets. Maybe we can have "%[" be a literal open square bracket,
|> "%]" be a literal close square bracket, and "%%" be a literal
Would it be too much to ask why boost is trying to re-invent the wheel.
The extended printf format defined by X/Open works quite well, thank
you, and unless someone can point out some fatal flaw with it, I would
argue for sticking with it.
-- James Kanze mailto:kanze_at_[hidden] Conseils en informatique orientée objet/ Beratung in objektorientierter Datenverarbeitung Ziegelhüttenweg 17a, 60598 Frankfurt, Germany Tel. +49(0)179 2607481
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk