Re: Comparison chain
| From: | Nikita Popov | Date: | Fri, 05 Dec 2014 19:50:15 +0000 |
| Subject: | Re: Comparison chain | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79450@lists.php.net to get a copy of this message | ||
On Fri, Dec 5, 2014 at 3:47 PM, Andrea Faulds <ajf@ajf.me> wrote:
>
> > On 5 Dec 2014, at 14:36, Дмитрий <freax@pop3.ru> wrote:
> >
> > Hi!
> >
> > I followed by https://wiki.php.net/rfc/howto and I would
> > like to
> propose a concept "comparison chain" to implementing to future PHP versions.
> > It would be very usable if PHP can do that in python-style.
> >
> > Thank for your attension!
>
> Are you saying to allow (1 < x < 2) etc.? That would be nice, although
> it’s a backwards-compatibility break as currently (1 < x < 2) would do
> something different, as would, say, ($x == $y == $z).
>
Comparisons are non-associative in PHP [1], so something like $x == $y ==
$z is currently invalid code. As such this would not break compatibility.
Nikita
[1]: http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#81