[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] style: don't use std::endl
From: |
Hans Åberg |
Subject: |
Re: [PATCH 5/5] style: don't use std::endl |
Date: |
Thu, 10 May 2018 15:07:39 +0200 |
> On 10 May 2018, at 14:58, Akim Demaille <address@hidden> wrote:
>
>> Le 10 mai 2018 à 14:01, Hans Åberg <address@hidden> a écrit :
>>
>>> On 9 May 2018, at 08:18, Akim Demaille <address@hidden> wrote:
>>>
>>>> Le 8 mai 2018 à 18:03, Hans Åberg <address@hidden> a écrit :
>>>>
>>>>
>>>>> On 8 May 2018, at 17:02, Akim Demaille <address@hidden> wrote:
>>>>>
>>>>> Don't use std::endl, it flushes uselessly, and is considered bad
>>>>> style.
>>>>
>>>> Flushing is good with debugging and error reporting, though.
>>>
>>> I agree, but in that case an explicit `flush()` is better.
>>> And in the case of Bison, I don’t think we need any.
>>>
>>> Besides, stdout is typically line buffered when connected to a terminal,
>>> and stderr is typically unbuffered.
>>
>> I can see this difference when throwing an uncaught exception: std::cerr is
>> output before the exception reporting, whereas std::cout after, when the
>> buffers are flushed in connection with program termination.
>
> Of course one can see differences in arbitrary programs. The
> question is whether my changes change something for users. Do
> you have an actual example?
For the std::cerr cases, if unbuffered, your changes will make no difference, I
gather, but I recall in my code in the past that when debugging in an
interactive debugger, one must be careful to flush. Then a problem with the
Bison files is that they are automatically written, so it can be a bother
trying to change it by hand.
- [PATCH 2/5] tests: we might need to find gnulib headers, (continued)
- [PATCH 2/5] tests: we might need to find gnulib headers, Akim Demaille, 2018/05/08
- [PATCH 3/5] gnulib: update, Akim Demaille, 2018/05/08
- [PATCH 4/5] doc: wrap, Akim Demaille, 2018/05/08
- [PATCH 1/5] getargs: rename argument to avoid gnulib's renaming, Akim Demaille, 2018/05/08
- [PATCH 5/5] style: don't use std::endl, Akim Demaille, 2018/05/08
Re: [PATCH 0/5] Update gnulib, and minor changes, Akim Demaille, 2018/05/09