Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Yasuo Ohgaki
Hi Stas, On Sat, Jan 24, 2015 at 8:42 AM, Stanislav Malyshev wrote: > > The only reasonable behavior for <==>, <==, >== would be raising > > error/exception if type differs. > > E_RECOVERABLE_ERROR may be used. > > Comparison operators raising exceptions doesn't sound like a very nice > thing to

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Andrea Faulds
Hi Stas, > On 23 Jan 2015, at 23:42, Stanislav Malyshev wrote: > >> The only reasonable behavior for <==>, <==, >== would be raising >> error/exception if type differs. >> E_RECOVERABLE_ERROR may be used. > > Comparison operators raising exceptions doesn't sound like a very nice > thing to work

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Stanislav Malyshev
Hi! > The only reasonable behavior for <==>, <==, >== would be raising > error/exception if type differs. > E_RECOVERABLE_ERROR may be used. Comparison operators raising exceptions doesn't sound like a very nice thing to work with. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP R

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Yasuo Ohgaki
Hi all, On Fri, Jan 23, 2015 at 8:05 PM, Andrea Faulds wrote: > > On 23 Jan 2015, at 10:02, Alain Williams wrote: > > > >> On Fri, Jan 23, 2015 at 12:24:25AM +, Andrea Faulds wrote: > >> > >> Having it be the same as === would be inconsistent with our existing > sorting and comparison behav

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Andrea Faulds
Hi Alain, > On 23 Jan 2015, at 10:02, Alain Williams wrote: > >> On Fri, Jan 23, 2015 at 12:24:25AM +, Andrea Faulds wrote: >> >> Having it be the same as === would be inconsistent with our existing sorting >> and comparison behaviour, so I don’t think it should be changed. If we made >>

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-23 Thread Alain Williams
On Fri, Jan 23, 2015 at 12:24:25AM +, Andrea Faulds wrote: > Having it be the same as === would be inconsistent with our existing sorting > and comparison behaviour, so I don’t think it should be changed. If we made > it strict like that, we’d also have to define a strict < and > as well, >

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Yasuo Ohgaki
Hi Andrea, On Fri, Jan 23, 2015 at 9:24 AM, Andrea Faulds wrote: > Having it be the same as === would be inconsistent with our existing > sorting and comparison behaviour, so I don’t think it should be changed. If > we made it strict like that, we’d also have to define a strict < and > as > well

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Yasuo Ohgaki
On Fri, Jan 23, 2015 at 9:43 AM, Yasuo Ohgaki wrote: > Ok. Now I understand. Since we don't/can't define strictly typed > less/greater than operator, > it makes sense. It can be handles > I always realize silly mistake after I sent mails :( It can be handled as > > if (get_type($a) != get_type($

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Andrea Faulds
Hi Yasuo, > On 23 Jan 2015, at 00:16, Yasuo Ohgaki wrote: > > Hi all, > > On Fri, Jan 23, 2015 at 7:48 AM, Larry Garfield > wrote: > >> The examples say nothing about mixing types, though. Eg, what would these >> return: >> >> return 0 <=> "0" >> >> return "" <=> 0 >> >> return 1 <=> [1,

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Andrea Faulds
Hey Yasuo, > On 23 Jan 2015, at 00:07, Yasuo Ohgaki wrote: > > 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 Yep, and I mentioned as much.

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Yasuo Ohgaki
Hi all, On Fri, Jan 23, 2015 at 7:48 AM, Larry Garfield wrote: > The examples say nothing about mixing types, though. Eg, what would these > return: > > return 0 <=> "0" > > return "" <=> 0 > > return 1 <=> [1, 2, 3] > > Ignoring object property names and going by the order of the property > de

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Yasuo Ohgaki
Hi Andrea, On Mon, Jan 19, 2015 at 5:28 PM, Andrea Faulds 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

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Andrea Faulds
Hi again, > On 22 Jan 2015, at 23:47, Larry Garfield wrote: > > Assuming it's accurate and I'm understanding you correctly, I think the > following would be a sufficient statement for the RFC: > > - > The behavior of this operator with mixed types is such that the following two > snippets

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Larry Garfield
On 01/22/2015 05:39 PM, Andrea Faulds wrote: Hi Larry, On 22 Jan 2015, at 22:48, Larry Garfield wrote: This looks potentially quite useful, especially for multi-stage comparisons as you note. Mainly it would mean I don't have to remember which direction is positive or negative, as I can ne

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Andrea Faulds
Hi Larry, > On 22 Jan 2015, at 22:48, Larry Garfield wrote: > > This looks potentially quite useful, especially for multi-stage comparisons > as you note. Mainly it would mean I don't have to remember which direction > is positive or negative, as I can never get that right without looking it

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-22 Thread Larry Garfield
On 01/19/2015 08:29 AM, Andrea Faulds wrote: Hey Nikita, On 19 Jan 2015, at 14:07, Nikita Popov wrote: I like the idea behind this (exposing internal compare_function), but I don't want to have an extra operator for a minor use case. Please just introduce a function instead. I originally w

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Stanislav Malyshev
Hi! > The operator is also less clear ... if I see "$a <=> $b" and do not happen > to be familiar with another language implementing this operator, I won't That can be said about every syntax construct - if you never seen it before, you'd have to learn. <=> is used in Perl, Ruby and Groovy - so i

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Andrea Faulds
Hi Alain, > On 19 Jan 2015, at 12:53, Alain Williams wrote: > > On Mon, Jan 19, 2015 at 12:30:14PM +, Andrea Faulds wrote: >> >> >>> On 19 Jan 2015, at 11:06, Alain Williams wrote: >>> >>> I like it. >>> >>> The RFC does not say what the precedence is to be. Could I suggest that it >>>

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Nikita Popov
On Mon, Jan 19, 2015 at 9:28 AM, Andrea Faulds wrote: > Good morning, > > 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.p

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Andrea Faulds
Hey Nikita, > On 19 Jan 2015, at 14:07, Nikita Popov wrote: > > I like the idea behind this (exposing internal compare_function), but I don't > want to have an extra operator for a minor use case. Please just introduce a > function instead. I originally wanted a function, but an operator has

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Mike Willbanks
Hi Andrea, On Mon, Jan 19, 2015 at 2:28 AM, Andrea Faulds wrote: > Good morning, > > 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: ht

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Alain Williams
On Mon, Jan 19, 2015 at 12:30:14PM +, Andrea Faulds wrote: > Hi Alain, > > > On 19 Jan 2015, at 11:06, Alain Williams wrote: > > > > On Mon, Jan 19, 2015 at 08:28:17AM +, Andrea Faulds wrote: > > > >> The RFC is here: https://wiki.php.net/rfc/combined-comparison-operator > > > > I like

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Andrea Faulds
Hi Alain, > On 19 Jan 2015, at 11:06, Alain Williams wrote: > > On Mon, Jan 19, 2015 at 08:28:17AM +, Andrea Faulds wrote: > >> The RFC is here: https://wiki.php.net/rfc/combined-comparison-operator > > I like it. > > The RFC does not say what the precedence is to be. Could I suggest that

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Benjamin Coutu
I wouldn't mind T_SPACESHIP, but T_THREEWAY_COMPARISON is probably more technically precise and better than T_COMBINED_COMPARISON. Cheers, Ben == Original == From: Jordi Boggiano To: Andrea Faulds Date: Mon, 19 Jan 2015 12:20:32 +0100 Subject: Re: [PHP-DEV] [RFC] Com

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Jordi Boggiano
On 19/01/2015 10:40, Andrea Faulds wrote: Hi Jordi, On 19 Jan 2015, at 10:37, Jordi Boggiano wrote: On 19/01/2015 08:28, Andrea Faulds wrote: Good morning, This is a reboot of Davey Shafik’s RFC (with permission). After recent discussions about sort functions, I was inspired to bring this

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Alain Williams
On Mon, Jan 19, 2015 at 08:28:17AM +, Andrea Faulds wrote: > The RFC is here: https://wiki.php.net/rfc/combined-comparison-operator I like it. The RFC does not say what the precedence is to be. Could I suggest that it be the same as ''== != === !== <>'' - which keeps it consistent with Perl.

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Andrea Faulds
Hi Jordi, > On 19 Jan 2015, at 10:37, Jordi Boggiano wrote: > > On 19/01/2015 08:28, Andrea Faulds wrote: >> Good morning, >> >> 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 w

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Jordi Boggiano
On 19/01/2015 08:28, Andrea Faulds wrote: Good morning, 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-co

Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Benjamin Coutu
This would be indeed very useful and also ideal from a sorting performance perspective! == Original == From: Andrea Faulds To: PHP internals Date: Mon, 19 Jan 2015 09:28:17 +0100 Subject: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator Good morning, This is a

[PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator

2015-01-19 Thread Andrea Faulds
Good morning, 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 Thanks! -- Andrea Faulds