[RFC] Interval Comparison

From: Date: Sun, 06 Nov 2016 20:29:13 +0000
Subject: [RFC] Interval Comparison
Groups: php.internals 
Request: Send a blank email to internals+get-96746@lists.php.net to get a copy of this message
Validating whether a number is within a closed or open interval is currently possible only via a construct like the following: ``` if (0 < $x && $x < 42) { echo 'x is in (0, 42)'; } if (0 <= $x && $x <= 42) { echo 'x is in [0, 42]'; } ``` It is not very readable and repetitive. It would be interesting to support a more mathematical notation for this: ``` if (0 < $x < 42) { echo 'x is in (0, 42)'; } if (0 <= $x <= 42) { echo 'x is in [0, 42]'; } ``` I cannot judge how complicated it is to extend the Bison definitions to allow this. However, if there is interest I'm sure there is a way. :) -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#96746) next »