Re: [RFC] Combined Comparison (Spaceship) Operator
| From: | Yasuo Ohgaki | Date: | Fri, 23 Jan 2015 00:07:35 +0000 |
| Subject: | Re: [RFC] Combined Comparison (Spaceship) Operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81004@lists.php.net to get a copy of this message | ||
Hi Andrea,
On Mon, Jan 19, 2015 at 5:28 PM, Andrea Faulds <ajf@ajf.me> wrote:
> This is a reboot of Davey Shafik’s RFC (with permission). After recent
> discussions about sort functions, I was inspired to bring this back up, as
> I think it would be a useful feature.
>
> The RFC is here:
> https://wiki.php.net/rfc/combined-comparison-operator
>
Ruby has it. Semantics is the same.
http://ruby-doc.org/core-1.9.3/Comparable.html
PERL has it. Semantics is the same.
http://perldoc.perl.org/perlop.html#Operator-Precedence-and-Associativity
Python has similar "<>", but it only compares equality. (the same as !=,
!==)
[yohgaki@dev github-php-src]$ python
Python 2.7.8 (default, Nov 10 2014, 08:19:18)
[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> 1 <> 1
False
>>> 1 <> 0
True
>>> 1 <> 1
False
>>> 1 <> 2
True
MySQL has it. Different differs. It's for NULL comparison.
http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#operator_equal-to
There is no reason not to have it, it seems.
I suggest to add Ruby/PERL operator link to the RFC.
I would like to name it other than T_SPACESHIP.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net