On 11 January 2018 at 11:28, David Brown wrote:
> On 11/01/18 11:13, Jonathan Wakely wrote:
>> t all cleaOn 11 January 2018 at 10:05, David Brown wrote:
>>> Maybe it is easier to say "gcc supports <=> in C++2a, and as an
>>> extension also supports it in C and C++ of any standard" ?  I don't
>>> believe there is any way for it to conflict with existing valid code, so
>>> it would do no harm as a gcc extension like that - and C users can then
>>> use it too.
>>
>> It's not very useful in C because you need the comparison category
>> types, which are classes defined in <compare> (see
>> http://en.cppreference.com/w/cpp/header/compare)
>>
>> C doesn't have those types, and can't define anything close.
>>
>
> Surely you can get very close by simply returning an int, value -1, 0 or
> 1?  That is what other languages (like PHP) do for their <=> operator.
> There are complications - such as for floating point when you have NaNs.
>  But I think you could have a very successful operator if you defined "a
> <=> b" to be the same as "(a > b) - (a < b)".
>
> Whether it would be particularly /useful/ or not is another matter.  I
> was thinking mainly in terms of saving effort when making C++2a support
> - rather than having to making the new operator conditional on a
> particular version of the standards, it could be accepted in any version.

It seems like the wrong trade-off. We have dozens of features that
depend on the standards mode, we know how to do that.

Simply slamming a new language feature in all modes (*and* in a
different language with a different front-end!) to save a small amount
of effort doesn't seem like a good idea to me. Especially if it then
doesn't even work the same pre-C++2a, as know we need to test it in
additional ways.

Reply via email to