Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20588 invoked from network); 12 Nov 2016 16:56:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Nov 2016 16:56:27 -0000 Authentication-Results: pb1.pair.com header.from=dave+php@mudsite.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dave@mudsite.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mudsite.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: dave@mudsite.com X-Host-Fingerprint: 209.85.217.182 mail-ua0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:34716] helo=mail-ua0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/02-05927-AB947285 for ; Sat, 12 Nov 2016 11:56:27 -0500 Received: by mail-ua0-f182.google.com with SMTP id 51so35476652uai.1 for ; Sat, 12 Nov 2016 08:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mudsite-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E07EEfdODsgmbNok/PC+oY6dzJnHO03IfvkMcVOLMaU=; b=LDGJolwAbad5QXpni4dRXCVLRk2uNanLu3+lTcvLaEyFHb9wsJkaQF5FZ394wWZCUq f0yRQCWSyeXvB7+AQuPoAO7A7kTHNPQ4cFhVaAj677aNR3ycXW7gLvSFs3uhadLX7tfA 1iJLKbJMEE/dVd/jmbM1amzB0K105n+ZTiqEVdqUDAPzSn1/aVsWBFOfPGItShYboXGK Eo7E1HND0Bdh71HIAXc/bZ4GvXZDhcDzC90F4G/rSeVghNjUFFDav3BDW2/PXmBqOnVy MJWX6VgeFNCC8F1IToXoEy0qCHw44XGww7CsbNfAk5s8g9QTNGm7HZwVcba5W2pB6XH8 WX4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E07EEfdODsgmbNok/PC+oY6dzJnHO03IfvkMcVOLMaU=; b=kpd+fAaan70nRWmFhkioUCcAYvGnGRCEZno89GfsF3Z3Dxia9CzBF5SfPV7db/n4QT MPqmPCLaRFxj9jcHCyhhMnTJUdTzTIWrZfCDQdIW49LSynUaCALwSDSHQdMEEf+x0ltI KXFm3p5tnsxiNX3AOfrBSKZrVueBWbvaCvzxNjdbDcMdn00ff/XWH3YlAFryZuRoaDy6 7dtZWWGF6KVQBljyRffixF+eWbksgZVctW0J1JxCSUEOR5YEGy4J+ei338vrTgZ90AVr CHcumaxnFm/qPnDSBYc8CVZ2UB+6dsR+QZkRBgMjnz1CqM55D5obk5tF5HPmcDfB2zwD esEw== X-Gm-Message-State: ABUngvdyAg6gWeVrNuzAZWjkMuyZuOv9AXZeRHa5tUk47/S3NPGJFb09mVBtP8io+hmdupw2fYScCwioiJt28g== X-Received: by 10.176.81.82 with SMTP id f18mr5401058uaa.119.1478969784012; Sat, 12 Nov 2016 08:56:24 -0800 (PST) MIME-Version: 1.0 References: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> <9a84054848086fa4c2965f93dd3b56a3@gmail.com> In-Reply-To: Date: Sat, 12 Nov 2016 16:56:13 +0000 Message-ID: To: "Christoph M. Becker" , =?UTF-8?Q?Lauri_Kentt=C3=A4?= Cc: "internals@lists.php.net >> PHP Internals" , Andrea Faulds Content-Type: multipart/alternative; boundary=94eb2c1913b69c227305411d7c42 Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: dave+php@mudsite.com (David Walker) --94eb2c1913b69c227305411d7c42 Content-Type: text/plain; charset=UTF-8 On Sat, Nov 12, 2016 at 9:47 AM Christoph M. Becker wrote: > 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: > Double my oops, I meant a pre-increment. > > > 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] > I concur with this, that each term should only be evaluated once, in more what Lauri defined: a < ($tmp1 = b) && $tmp1 < ($tmp2 = c) && $tmp2 < d Which would ensure that each position is evaluated once, in a left->right fashion. And I doubly concur that evaluation is short circuited (per my wrong example, you corrected): $a = 0 1 < $a++ < $a++ < 3 ~~ 1 < 1 // false. $a would be 1 after this line. -- Dave --94eb2c1913b69c227305411d7c42--