|
Boost : |
From: Samuel Krempp (krempp_at_[hidden])
Date: 2001-12-20 19:25:34
On Fri, 2001-12-21 at 00:14, Karl Nelson wrote:
> > > Of course if it turns out there are other killer arguments in favor of the
> > > string-maker approach, you should choose string-maker.
> >
> > I doubt I'll ever find killer arguments for string-builder vs
> > manipulator.. at best, several vague inconveniences in the manipulator
> > approach, but not much more.
>
> Given that there are only vague inconveniences I personally think
> the one which looks most familiar to the user is the best. We are basically
> trading one set of inconviences for another.
it's more like trading a set of painful exceptions,
for a slightly harder initial acclimatation to the class's construct.
This (IMO overestimated) impact of '%' on the user's ability to
understand how to use the class
would be reduced a lot by a proper doc.
consider the following introduction :
(using ross's smith proposal of the call operator notation rather than
%) :
--------------------------------------
With format, The equivalent to :
printf("at step %6d, x= %5.3e \n", i, x);
is :
cout << pformat("at step %6d, x=%5.3e \n") (i) (x);
Note that arguments are passed one by one, through the call operators,
as this is a robust way to pass any number of arguments to the format
object.
You can also take the string value of the formatting :
string s = str( pformat("at step %6d, x=%5.3e \n") (i) (x) );
Note that
cout << str( pformat("at step %6d, x=%5.3e \n") (i) (x) );
produces exactly the same output with or without the call to str(..).
--------------------------------------
In 10 lines, the constructs allowed by the class are described. No
shadow zone left aside, no special cases..
If the user tries something more complex, it will work as intended,or
fails immediately.
So, okay, the user will need 2 minutes to get familiar with the use of
the operator dedicated to arguments-passing.
(be it '%' or () )
But that's nothing. On the other hand, he won't have to read lots of
details about what he can do, or can't, how he should use endf, how to
do nested formats, ...
Using a metaphor, the first step of the staircase of learning the class
might be higher for my class, but I beleive its total height is lower
than yours.
regards
-- Samuel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk