|
Boost : |
From: Dave Gomboc (dave_at_[hidden])
Date: 2002-02-11 19:07:03
> > > 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);
> >
> > It certainly does.
>
> It disagree. It may be slightly easier to read for those new to the
> system, but it is a more complicated syntax and therefore harder to
> write correctly. Is it "hex" or "hexadecimal"? "width" or "w"?
> "padding" or "pad"? And how is this option spelled anyway? All of
> these problems go away with a terse printf style single character
> syntax.
"These problems" are easy to solve: Peter Dimov already suggested a
mechanism by which the use of both "hex" and "hexadecimal" could be
permitted. "width" is obvious; "padding_char" (only because C++ uses
char, not character) is straightfoward. Another mechanism (though I'm
happy with Peter's) would be to allow any unique prefix to be used
(giving "hex", "dec", "pad", "padding", etc.).
What you didn't address was the problem of the relative illegibility of
over-terse syntax. People who really like terse syntax can continue
using printf/sprintf/fprintf. Why force that on the rest of us?
I reject the claim that the longer forms are more difficult to write
correctly. IMO, precisely the opposite is the case. They are also
easier to read correctly. Furthermore, they are also easier to
remember, easier to refer to when discussing aloud with a colleague,
easier to teach, and easier to learn. Sure, they're more cumbersome for
those who type with just their two index fingers, but frankly, that's
not something I am deeply concerned about.
Dave Gomboc
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk