On Wed, Nov 23, 2011 at 12:59:00PM +0000, Michael Meeks wrote:
The attached test contrasts:
fprintf (stderr, "P is %s and b is %d\n", p, b);
vs.
std::cout << "P is " << p << " and b is " << b << "\n";
Given that the real per-site difference is larger. Add to this
the issue that there are real translation problems with the 2nd
approach (that it cannot be appropriately re-ordered), and IMHO the
argument here is overwhelmingly against 'cute' operator-overloading
approaches
Translation? Isn't that for debug logging? Do we translate the strings
in OSL_TRACE et al? That seems like wasted time...
Anyway, for a developer not already well acquainted with the code, the
C++ streams approach has the *huge* advantage that (s)he can add
debugging printfs without finding out how to transform *this* object
into a zero-terminated array of characters. If it makes sense to do
it, just use "<<" and it will do the right thing. *Much* easier.
Also, more generally, in the face of platform-dependent typedefs of
integer types, *I*, for one, never really know which length modifier
to use in the format string :-( %d? %ld? Look at how glibc had to
solve this issue with an extension length modifier 'z' just so that
people can print the size of something!
If I were dictator, the "printf-like format string" approach would be
proscribed. I'm not dictator ;-)
--
Lionel
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.