From: David Brown <david@westcontrol.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: Tim van Deurzen <tim@kompiler.org>,
Jason Merrill <jason@redhat.com>,
"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Implementing p0515 - spaceship operator
Date: Thu, 11 Jan 2018 11:29:00 -0000 [thread overview]
Message-ID: <5A574A78.4040609@westcontrol.com> (raw)
In-Reply-To: <CAH6eHdRSWwm-AWmGbhhqg93HA5aS66bUPNL6vX0phAz8KjFbwg@mail.gmail.com>
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.
> And it's non-conforming to declare those types in pre-C++2a, because
> the names could be used by user programs.
>
> Potentially the types could be defined with reserved names like
> __strong_ordering, and then make std::strong_ordering a typedef for
> that, but there are also changes to the language spec that go with the
> new operator, and enabling those pre-C++2a could change the meaning of
> valid code.
>
> So it's not ar it does no harm.
>
next prev parent reply other threads:[~2018-01-11 11:29 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 21:07 Tim van Deurzen
2018-01-08 22:08 ` Jason Merrill
2018-01-08 22:13 ` Jonathan Wakely
2018-01-08 22:29 ` Jason Merrill
2018-01-09 22:56 ` Tim van Deurzen
2018-01-10 13:00 ` Jonathan Wakely
2018-01-10 21:24 ` Tim van Deurzen
2018-01-10 21:32 ` Jakub Jelinek
2018-01-10 21:38 ` Tim van Deurzen
2018-01-11 10:06 ` David Brown
2018-01-11 10:13 ` Jonathan Wakely
2018-01-11 10:15 ` Jonathan Wakely
2018-01-11 11:29 ` David Brown [this message]
2018-01-11 11:32 ` Jonathan Wakely
2018-01-11 11:32 ` Jonathan Wakely
2018-01-11 11:42 ` David Brown
2018-01-11 14:06 ` Joseph Myers
2018-08-30 18:07 ` Jakub Jelinek
2018-08-30 18:16 ` Marek Polacek
2018-09-03 21:04 ` Tim van Deurzen
2018-09-26 15:01 ` Jason Merrill
2018-09-27 20:58 ` Nathan Sidwell
2018-11-05 1:23 ` Jason Merrill
2018-11-05 7:36 ` Jason Merrill
2018-11-05 7:40 ` Tim van Deurzen
2018-11-05 8:07 ` Jakub Jelinek
2018-11-05 16:03 ` Tim van Deurzen
2018-11-06 12:35 ` Jason Merrill
2018-01-09 18:01 ` Nathan Sidwell
2018-01-09 16:10 ` Martin Sebor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5A574A78.4040609@westcontrol.com \
--to=david@westcontrol.com \
--cc=gcc@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=jwakely.gcc@gmail.com \
--cc=tim@kompiler.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).