atom feed10 messages in net.php.lists.internals[PHP-DEV] [RFC] Combined Comparison O...
FromSent OnAttachments
Davey ShafikFeb 12, 2014 7:58 pm 
Davey ShafikFeb 12, 2014 8:39 pm 
Simon J WelshFeb 12, 2014 9:07 pm 
Christian StollerFeb 12, 2014 11:19 pm 
Tjerk MeestersFeb 12, 2014 11:56 pm 
Johannes SchlüterFeb 13, 2014 3:04 am 
Davey ShafikFeb 13, 2014 10:04 am 
Davey ShafikFeb 13, 2014 1:28 pm 
Ivan...@ HoaFeb 14, 2014 2:41 am 
Rowan CollinsFeb 14, 2014 8:10 am 
Subject:[PHP-DEV] [RFC] Combined Comparison Operator
From:Davey Shafik (dav@php.net)
Date:Feb 12, 2014 7:58:05 pm
List:net.php.lists.internals

Hey folks,

I've written up an RFC/Patch to gauge interest and get feedback on the addition of a combined comparison (aka: spaceship) operator.

You can see the RFC at: https://wiki.php.net/rfc/combined-comparison-operator

This adds a new operator "(expr) <=> (expr)" that returns 0 if both operands are equal, 1 if the left is greater, and -1 if the right is greater.

It works with all types (just as well as <, <=, >=, > work) and is great for usort() callbacks for example.

Code available here (against 5.6): https://github.com/dshafik/php-src/compare/add-spaceship-operator

I'd love to get this into 5.6, not sure if we hit feature freeze yet. Also, not sure if it needs 2/3 majority, but assumed so as pow did?

Thoughts?

If there is interest, I'll start adding tests. They should be fairly trivial.

- Davey