Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Type Traits Extension by Frederic Bron
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-03-16 08:49:41


Stewart, Robert wrote:
>
> Frédéric Bron wrote:
>>
>> >> There would seem to me to be a very strong case for having
>> >> the same names as in Boost.Proto and Boost.Operator.
>>
>> It would be difficult to have the same names as in Boost.Proto
>> and Boost.Operator as they are different. However Boost.Proto
>> seems to be the good candidates as it addresses all operators
>> which is not the case for Boost.Operator. Also many names are
>> already the same (see below).
>
> +1
>
>> type_traits Boost.Proto Boost.Operators binary
>>
>> == equal_to equal_to equality_comparable
>> != not_equal_to not_equal_to
>> < less less less_than_comparable
>> <= less_equal less_equal
>> > greater greater
>> >= greater_equal greater_equal
>> + plus plus
>> - minus minus
>> * multiplies multiplies
>> / divides divides
>> % modulus modulus
>> += plus_equal plus_assign addable
>

Please do not mix operators and concepts (equality_comparable, addable,
less_than_comparable) which are adjectives.

> Notice that "==" is about equality comparisons, so "equal" has to do with
> the operation rather than the symbol. Here, the operation is assignment
> (after addition), so "assign" is quite appropriate.
>
> By contrast, "plus" is about the symbol more than the operation. Thus,
> Proto's name is internally inconsistent. "add_assign" would be better.
>
>> -= minus_equal minus_assign substractable
>
> Ditto for "minus" versus "subtract."
>
>> *= multiplies_equal multiplies_assign multipliable
>
> I would prefer "multiply" to "multiplies," but it may be better to favor
> consistency with Proto.
>
>> /= divides_equal divides_assign dividable
>
> Ditto for "divide" versus "divides."
>

std::ratio uses add, subtract, multiply and divide, this corresponds to
verbs not to nouns and have a semantic associated.

Not also that we have Boost.MPL which has also some names for arithmetic
operators. It uses plus,minus,times and divides.

I think that that the names we are looking for should be names.

>
>> %= modulus_equal modulus_assign modable
>> & bit_and bitwise_and
>> | bit_or bitwise_or
>> ^ bit_xor bitwise_xor
>> &= bit_and_equal bitwise_and_assign andable
>> |= bit_or_equal bitwise_or_assign orable
>> ^= bit_xor_equal bitwise_xor_assign xorable
>
> FWIW, I always use "bitwise" rather than "bit" when I verbalize those
> operators.
>

+1

>> << left_shift shift_left
>> >> right_shift shift_right
>> <<= left_shift_equal shift_left_assign left_shiftable
>> >>= right_shift_equal shift_right_assign right_shiftable
>
> I find direction + "shift" the better order, but consistency with Proto
> might be the better thing.
>

+1 for direction + "shift"

>> && logical_and logical_and
>> || logical_or logical_or prefix
>> + unary_plus unary_plus
>> - unary_minus negate
>
> An odd inconsistency in Proto, unless "negate" was actually from
> Operators.
>
> I generally like the names from Proto. Consistency would be nice, but
> consider the names as they are likely to be standardized. Better to get
> the names "right" now. For example, I think "postfix_increment" is a
> likely name for standardization, while "post_inc" is not.
>
>
"postfix_increment" is already in use on the standard:
"Increment and decrement [over.inc]
1 The user-defined function called operator++ implements the prefix and
postfix ++ operator. If this function is a member function with no
parameters, or a non-member function with one parameter of class or
enumeration type, it defines the prefix increment operator ++ for objects of
that type. If the function is a member function with one parameter (which
shall be of type int) or a non-member function with two parameters (the
second of which shall be of type int), it defines the postfix increment
operator ++ for objects of that type. When the postfix increment is called
as a result of using the ++ operator, the int argument will have value
zero."

pre-increment and post-increment are also already used in the standard. E.g.

"raw_storage_iterator&lt;OutputIterator,T&gt;& operator++() noexcept;
Effects: Pre-increment: advances the iterator and returns a reference to the
updated iterator. raw_storage_iterator&lt;OutputIterator,T&gt;
operator++(int) noexcept;
Effects: Post-increment: advances the iterator and returns the old value of
the iterator."

"post- increment operator (operator++)."

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/Review-Boost-Type-Traits-Extension-by-Frederic-Bron-tp3353283p3381645.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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