[boost] Re: Re: Re: I/O library status
by Ed Brey other posts by this author
Jun 4 2003 8:18PM messages near this date
[boost] Re: Re: I/O library status
|
RE: [boost] Re: Re: I/O library status
Paul A. Bristow wrote:
> >
> > cout <<
> > "My first line" "\n"
> > "My second line";
>
> Are you sure that this is more efficient?
>
> cout <<
> "My first line" << endl <<
> "My second line";
>
> has proven LESS efficient and I suspect the flush caused by
> encountering \n will have the same effect. Of course, the
> differences are tiny in practice.
I just did a test using VC7.1: '\n' did not trigger a flush. Assuming that is the correct b
ehavior, that does indeed make the string concatenation method the most efficient.
> I view the newl as much clearer. And the concept that endl actually
> writes the buffered output doesn't seem too complicated.
>
> As a non-C programmer, "\n" looks plain nasty to me :-(
It looks like the intent of newl is to take the place of '\n' is the C++ language, as a way
to improve C++ from a syntactical standpoint. I think that such a goal should be handled wi
th an overall view of the language, rather than with just an isolated view of I/O streams.
The larger question would address how the '\n' replacement interacts with strings, including
string concatenation and operator overloading.
I'd say it would be an interesting issue to raise on comp.lang.c++, except for one thing: it
would be hard to demonstrate how one abbreviation is better than another and worth a langua
ge change, especially when complicated by the precipitating changes required to harmonize '\
t', '\r', etc.
_______________________________________________
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
|