|
Boost : |
From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-11 14:00:05
> From: James Kanze [mailto:kanze_at_[hidden]]
> >
> > There's not just a problem of code compatibility; there's user
> > compatibility. People know printf; any new format, they'd have to
> > learn. If there are strong reasons for abandonning printf
> > format, then
> > it should certainly be done, but it shouldn't be done on a whim.
>
> Don't lump everyone into the same state. I've used printf() in the past,
> but I never used it extensively, and I always had to look up anything but
> the most basic format specifiers. Even today, when I find it necessary to
> use a printf() variant, I often try to use %i instead of %d for an integer.
> There are increasing numbers of C++ programmers that have rarely or never
> used printf(); they were weaned on IOStreams.
I would never attempt to argue that the letter assigned to printf
make much sense, but then unless we want a very verbose format
string they can't be less than cryptic.
Does this really add a whole lot of value
cout << format("%{1:hex,width=10,pad=0} %{2:dec}")(a)(b);
over
cout << format("%010x %d")(a)(b);
(Mind you I suggest the %{} because they are backwards compatible
allowing format("%s %{hex,width=10,pad=0}"))
However, no matter what format has been suggested if it has got
some level of format specifiers you immediately have to have the
programmer potentially look at a table to see what is supported.
> Given that by no means does everyone "know printf," abandoning print() is
> not at all unreasonable, even on a whim. (Ok, not just on a whim, but I
> would have absolutely no problem with totally abandoning the printf() format
> specifiers for something less cryptic, equally capable, with type safety.
Abandoning printf on a whim is unreasonable. It is a standard and
thus deviating from it means imposing some new standard. Creating
standards on a whim is what Microsoft does.
The arguments for using printf are that
- it is known by a reasonable large group of C/C++ programmers
- the format specifier is stardardized by both Unix and C.
- it appears already in C++ in the form std::printf and friends
- using multiple standards in a translation database is likely
to lead to errors and difficulties for translators who
may not be viewing the source code.
--Karl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk