On 2016-11-07 23:51, David Walker wrote:
On Mon, Nov 7, 2016 at 1:38 PM Fleshgrinder <p...@fleshgrinder.com>
wrote:
We are only extending binary to ternary for <= and <.
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 (<, <=, >, >=).
I'm pretty sure that a three-part comparison is easier to implement. It
can be kind of hard-coded as a new type of syntax, somewhat like the
ternary operator.
Personally I'd prefer the full Python-style chaining. It's a lot more
useful, especially for cases like 0 < $a <= $b < $upper_limit.
One possible implementation idea (not knowing anything about Zend):
Comparison (a<b) would return a pair of data, the result and the latter
value. If this was the last comparison or the result was false, the
value will be dropped and the comparison ends. Else the result (true)
will be dropped and the comparison will go on.
--
Lauri Kenttä
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php