From: Brey, Edward D (EdwardDBrey_at_[hidden])
Date: 2002-01-31 09:42:31
> From: bill_kempf [mailto:williamkempf_at_[hidden]]
> My own opinion is that generalized formatting is already handled
> quite nicely by iostream manipulators any way (the only two arguments
> I've ever heard against this was that "printf" was more intuitive,
> which is true only for old C coders, and that the manipulator
> approach was very verbose, but I could care less about that).
Verbosity does make a difference. Fortunately, the difference can be
explained in terms other than the nebulous "intuition factor" or
It's a matter of engineering principle: locality of reference, as applied to
its impact on the programmer. With the printf-style, you get good locality
of the format text:
"Task  will complete within  second(s)."
That is to say, it is easy to see the flow of the sentence, the correlation
between "Task" and "will complete", for example.
With stream style, you get good locality of the variables to their
"Task " << task_name << " will complete within " <<
estimated_completion_time - current_time() << " second(s)."
Here it is easy to pair "Task" and "task_name", for example.
Each type of locality has its own advantage. There is a tradeoff, and which
style is best depends on the situation. In my experience, I've found that
when dealing with full English sentences, the locality of the format context
is most desirable, whereas for short, simple outputs, like those in some
trace logs, locality of a variable to its text is most desirable.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk