Boost logo

Boost :

Subject: Re: [boost] [atomic] (op)_and_test naming
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2018-01-26 00:50:47


On 26/01/2018 12:03, Peter Dimov wrote:
>> Consistency within this domain should be sufficient.
>
> Consistency and intuition are in conflict here. These function are
> presently specified the way they are specified for a reason - this is
> what makes more sense in the context in which they are typically used.
> You can use consistency to justify a choice, but you can't magically
> make people not be confused by the choice.

I disagree. Both consistency with other existing methods and intuition
with C++'s conventions (nonzero is truthy) agree that the current
implementation is unexpected. So there is no conflict there.

Bringing the conventions of other domains (what assembly instructions
do, what the shell 'test' command does, what language X's 'test' keyword
does) into play is a non-argument and not relevant.

"sub_and_test_if_zero" could be a valid (though wordy) name for the
current implementation of the method.

I would prefer if "sub_and_test" (or to prevent breaking changes, an
alternate spelling like "sub_test") would instead return true when
non-zero, thus following both consistency and intuition.

> This is similar to the bool conversion of std::error_code, which is also perfectly consistent and still manages to return the opposite of what a certain fraction of the audience intuitively expects.


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