Boost logo

Boost :

From: Mattias Flodin (flodin_at_[hidden])
Date: 2002-04-09 02:58:33


On Tue, Apr 09, 2002 at 04:46:53AM +0000, Eugene Karpachov wrote:
> 9 Apr 2002 05:55:49 +0400 Ernie Makris wrote:
> > It would look like the following:
> > log << log_debug << log_format("%e %1") % "config file not found";
>
> Please not that ugly format string again! Streams was invented to get
> out of this cryptic, type-unsafe and processor-time-consuming feature,
> so why not just to:
>
> log << log_debug << log_errno() << " config file not found";

Which is more readable?

cout << "CPU " << cpu_number << " (mem" << free_mem << "): multiply " <<
    rows << " X " << cols << " matrix, mode = " << "'" << transpose_mode <<
    "'" << endl;

versus

printf("CPU %d (mem %d): multiply %d X %d matrix, mode = '%c'\n",
    cpu_number, free_mem, rows, cols, transpose_mode);

Personally, I think the latter. It is interesting to note that the PRINT
statement in BASIC had cout-style printing from the start; the printouts were
concatenated using ";" or "," operators, if one can call them operators.
However, for the sake of readability and ease-of-use, many dialects later
added the PRINT USING statement that allowed to you to provide a (type
independent, i.e. no loss of type safety) format string first, and then let
the arguments to the string follow. I use iostreams because it is typesafe
and extensible, definitely not because it looks nice.

Anyway, I do not intend to claim I am holding the one truth, but I claim to
have good arguments for my point of view. What I wanted to get to is, this
seems like something that should be governed by a policy, if there is ever a
design decision in the library that would force the user to use either of the
two output methods. Currently however, it seems to me that log_format() is
just used at the choice of the user and not a strict requirement for getting
something useful into the logfile.

/Mattias

-- 
Mattias Flodin <flodin_at_[hidden]>  -  http://www.cs.umu.se/~flodin/
Room NADV 102
Department of Computing Science
Umeå University
S-901 87 Umeå, Sweden
--
"If there's anything more important than my ego around, I want it
caught and shot now."  -- Zaphod Beeblebrox

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk