Hi Larry, > On 22 Jan 2015, at 22:48, Larry Garfield <la...@garfieldtech.com> 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 up. > :-)
Glad you like it. I, too, sometimes have trouble remembering what direction it goes in. > 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 > definition seems like asking for trouble, too. > > There may be easy logical answers to the above given PHP's existing type > juggling, but they should be called out explicitly in both the RFC and in any > subsequent documentation. The behaviour would be the same as the current <, <=, ==, >= and > operators. If > currently returns TRUE, then it is 1, if == currently returns TRUE, then it is 0, and if < currently returns TRUE, then it is -1. Despite all the ridiculousness of our existing comparison rules, apparently <, == and > returning TRUE are mutually exclusive, thank goodness. I don’t really want to cover this behaviour in the RFC, because explaining it in full is a considerable effort and the rules it uses are not new, they are the ones PHP already uses. The behaviour for arrays is perhaps a little odd, but that is our existing behaviour, and I’d rather not introduce inconsistency by making <=> use different rules to the other operators. I agree, however, that documentation for this feature should mention the behaviour, possibly just linking to our existing documentation on type juggling. Thanks. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php