Hi again,

> On 22 Jan 2015, at 23:47, Larry Garfield <la...@garfieldtech.com> 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 produce the exact same result in all cases:
> 
> return $a <=> $b;
> 
> if ($a > $b) {
>  return -1;
> }
> elseif ($a < $b) {
>  return 1;
> }
> else {
>  return 0;
> }
> -----
> 
> Or maybe that's implicit in the existing link, I'm not sure.  (Now that I 
> read it over again.) Basically, in order to understand the more esoteric type 
> juggling that may occur you'd need to mentally expand it to its "uncompressed 
> form", for which the rules are already defined (if possibly quirky in some 
> cases).

Yes, that’s correct. Although it would be more accurate to say that ($a < $b) 
is just ($a <=> $b === -1), ($a > $b) is just ($a <=> $b === 1) and similar 
things for >= and <=, as that’s how the comparison operators work internally 
(with the exception of == which also has a fast case).

I think I’ll add something along those lines to the RFC.

Thanks.
--
Andrea Faulds
http://ajf.me/





--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to