Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96840 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65156 invoked from network); 12 Nov 2016 10:08:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Nov 2016 10:08:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=lauri.kentta@gmail.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=lauri.kentta@gmail.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain gmail.com does not designate 188.117.41.47 as permitted sender) X-PHP-List-Original-Sender: lauri.kentta@gmail.com X-Host-Fingerprint: 188.117.41.47 mailgateway.locotech.fi Linux 2.6 Received: from [188.117.41.47] ([188.117.41.47:47164] helo=mailgateway.locotech.fi) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/0F-35596-D1AE6285 for ; Sat, 12 Nov 2016 05:08:30 -0500 Received: from localhost (mailgateway [127.0.0.1]) by mailgateway.locotech.fi (Postfix) with ESMTP id 210BDA364D6; Sat, 12 Nov 2016 12:08:26 +0200 (EET) X-Virus-Scanned: amavisd-new at locotech.fi X-Spam-Flag: NO X-Spam-Score: -1.998 X-Spam-Level: X-Spam-Status: No, score=-1.998 tagged_above=-9998 required=5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=0.9] autolearn=no autolearn_force=no Received: from mailgateway.locotech.fi ([127.0.0.1]) by localhost (mailgateway.locotech.fi [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oOjtQ9KtromG; Sat, 12 Nov 2016 12:08:14 +0200 (EET) Received: from posti.fimnet.fi (posti.fimnet.fi [172.16.1.44]) by mailgateway.locotech.fi (Postfix) with ESMTP id 9B0C7A364AC; Sat, 12 Nov 2016 12:08:08 +0200 (EET) Received: from k-piste.dy.fi (unknown [172.16.1.39]) by posti.fimnet.fi (Postfix) with ESMTPSA id 63EA5101CA5; Sat, 12 Nov 2016 12:08:08 +0200 (EET) Received: from localhost.localdomain ([::1] helo=k-piste.dy.fi) by k-piste.dy.fi with esmtp (Exim 4.87) (envelope-from ) id 1c5VEG-0005HN-50; Sat, 12 Nov 2016 12:08:08 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sat, 12 Nov 2016 12:08:08 +0200 To: David Walker Cc: internals@lists.php.net, Andrea Faulds In-Reply-To: References: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> Message-ID: <9a84054848086fa4c2965f93dd3b56a3@gmail.com> X-Sender: lauri.kentta@gmail.com User-Agent: Roundcube Webmail/1.2.2 Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: lauri.kentta@gmail.com (=?UTF-8?Q?Lauri_Kentt=C3=A4?=) On 2016-11-11 19:03, David Walker wrote: > > I took a quick stab at implementing, and had something working for > constant expressions, but handling something akin to: > > $a = 2; > if (1 < $a++ < 3) { > ... > } > > Is a bit awkward in our expansions of : if (1 < $a++ && $a++ < 3). > Seems as if when processing the chain here, you'd need to see if the > left node has a child, and somehow ensure you get the evaluated value > somehow, to override the "left" node. So logically expansion of the > above would be if (1 < $a++ && 3 < 3). I think the same would have > too somehow handle (either by syntax error or something) that if a > non-numeric value creeps into a binary-op-compare we error like: if > (1 < (2==3) < 3). > > Just some food for thought > -- > Dave I don't see how you would ”logically” get 3 < 3. The very point of chaining is that each expression is evaluated only once, so the expression will have the same value in both of the comparisons. So if the first part is 1<2, then the other must be 2<3 (and not 3<3). An expression like a < b < c < d can be currently implemented with temporary variables like this: a < ($tmp1 = b) && $tmp1 < ($tmp2 = c) && $tmp2 < d -- Lauri Kenttä