Re: [RFC] Interval Comparison
| From: | Christoph M. Becker | Date: | Sat, 12 Nov 2016 16:47:59 +0000 |
| Subject: | Re: [RFC] Interval Comparison | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96859@lists.php.net to get a copy of this message | ||
On 12.11.2016 at 17:21, David Walker wrote:
> Should
> $a = 1;
> var_dump(1 < $a++ < 3);
>
> (expanded into numbers) be evaluated as:
> 1 < 2 && 2 < 3 - True
> or
> 1 < 2 && 3 < 3 - False
In my opinion, that should evaluate to
1 < 1 // false
because we have a post-increment operator, and it seems to me that the
expansion defined for Python[1] makes most sense:
> Comparisons can be chained arbitrarily, e.g., x < y <= z is
> equivalent to x < y and y <= z, except that y is evaluated only once
> (but in both cases z is not evaluated at all when x < y is found to
> be false).
[1] <https://docs.python.org/2/reference/expressions.html#not-in>
--
Christoph M. Becker