[boost] Re: Re: I/O library status
by Ed Brey other posts by this author
Jun 3 2003 1:48PM messages near this date
[boost] Re: I/O library status
|
[boost] Re: Re: Re: I/O library status
Thomas Witt wrote:
>
> 1. std::endl was and is still abused heavily. I think there is a
> reason for this. Most c++ programmers are taught to stay clear of
> ugly low-level c things and to use the new shiny c++ facilities
> instead. And that's what they do, replace '\n' with std::endl.
> Personally I believe this reason alone justifies a std library
> extension std::newl.
What are your thoughts on the "shininess" of std::newl? To me, newl still seems kind of cry
ptic, not much better than '\n'. Is the extra verbosity worth the downsides? I see a few d
ownsides:
* The general aliasing problem of having two ways to accomplish basically the same thing ('\
n' and newl) - it increases stylistic variances between different pieces of code and means a
higher learning curve for those who now have to know two constructs to read existing code.
* We currently have two constructs with different semantics, where the name doesn't provide
any hint of the difference between those semantics: endl and '\n'. Do we really want to add
one more such unhinting name to the hat. How is the user to be reminded that '\n' and newl
are almost the same, but not quite, whereas endl is the manipulator that provides the flush
?
* Since only '\n' works when forming strings, the same snippet of code could have both '\n'
and newl used together.
Beyond these are the performance concerns of course; that is that people may tend to use:
cout <<
"My first line" << newl <<
"My second line";
rather than the more efficient and arguably more readable:
cout <<
"My first line" "\n"
"My second line";
> 2. IIUC the difference between a character and a manipulator is that
> the manipulator is not tied to the streams character type. So for some
> applications '\n' does not suffice. To me stream.widen('\n') is
> sufficiently ugly to justify a newl modifier.
Could you elaborate here? I'm not up to speed enough to know where '\n' wouldn't get widene
d automatically. I agree that stream.widen('\n') is indeed ugly.
Ed
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Daryle Walker
Ed Brey
Ed Brey
Paul A. Bristow
Ed Brey
Thomas Witt
Paul A. Bristow
|