On 11/7/2016 10:51 PM, David Walker wrote: > Sense be damed ;-) . I'd attribute it to an identity of sorts (if it was > to go all out with comparison chaining). Yes it makes little sense, in > practice, but the truth of it would be the same. > > I realize that my comment, and question were going a bit off-topic with > going on about the chaining of comparisons, but I'm interested in it > more because I wonder which would be harder to implement. It would seem > to me that it would be harder to implement a means in which you only > allow one additional layer of comparison, rather than abstract chaining > of comparisons (<, <=, >, >=). As Andrea noted, python does allow for > arbitrary chains of comparison. I'm not exactly sure how precedence > would work with comparisons, rather, as I see it the comparison would > need to be expanded such > ``` > if (0 < $a < $b > 10) > ``` > would be akin to > ``` > if (0 < $a && $a < $b && $b > 10) > ``` > > I, of course, am only projecting a potential syntax, and I'm no yacc/ast > aficionado by any metric, but it'd seem to me that it'd be possible to > convert some stack of elements here into a recursive comparison. >
This requires associativity, as Python has it. https://docs.python.org/3/reference/expressions.html#comparisons The problem, as explained in the Python reference, is that in `x < y < z` the variables `x` and `z` are never compared against each other. This, however, works great almost always and nothing is wrong in doing so in my opinion. That change would actually be brutally easy since we only need to change the `%nonassoc` to `%left` and we are done. https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L73 -- Richard "Fleshgrinder" Fussenegger -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php