Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96746 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87859 invoked from network); 6 Nov 2016 20:29:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2016 20:29:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:41648] helo=mx207.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/66-33116-AA29F185 for ; Sun, 06 Nov 2016 15:29:32 -0500 Received: from cable-81-173-132-21.netcologne.de ([81.173.132.21] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1c3U4E-0002e5-Nx for internals@lists.php.net; Sun, 06 Nov 2016 20:29:26 +0000 Reply-To: internals@lists.php.net To: php-internals Message-ID: Date: Sun, 6 Nov 2016 21:29:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: [RFC] Interval Comparison From: php@fleshgrinder.com (Fleshgrinder) 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