Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96858 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15170 invoked from network); 12 Nov 2016 16:27:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Nov 2016 16:27:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:33653] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/01-05927-30347285 for ; Sat, 12 Nov 2016 11:27:48 -0500 Received: by mail-oi0-f51.google.com with SMTP id 128so17088381oih.0 for ; Sat, 12 Nov 2016 08:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=31tRrKSY4ii6I6yFZ+wLCAsMQOGvre9X8HWrEqlkRUA=; b=clT0jHwle5IjmKzxh8PYdhScRbcfPZ/rOA9WvvtXMVl5zUeupGm3mbfV/kNH6d8dkl XXw4iYzFQcPJJrDOtoSJkrzVgAHgZJCENxUnm+ymRF7TAwFUGeI1SzS9Qq3dhDjcUB10 ESQOUhx9IpNHtTpVPBbI14FTGiDW0GQjYBrgcfYxR28tYBK32YCq424UAGvFO8HTfyV/ mUN2OpqxeRZXFH0IyXv+wlNqCsbyuXoemZsTkr0Sa43mAO4AnMwusz52sIxKFktPh3x4 7dB4I6KpEhvN2HUHZcJItE6Ms/jW6Mo1r/iF87S7H67pnGXzWVRZH5c0P9nvrYJMtfQZ iCeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=31tRrKSY4ii6I6yFZ+wLCAsMQOGvre9X8HWrEqlkRUA=; b=JRkhdHsIlp7pmv9jI9mSJtG8jaWTqaX4XiQgXQ/5tRoNX2PfzzfdiO205548WeiUKQ k0Y0ESDUERwUKNa2P6m1tjlPzdvRrChiDN5E3hoNF2VVi9qGr12jrSqYhKNMdANVgs8C DKztetx8XkPdDTt0ynpCAce2orYGeE5ucFY9ptHeu+wePu3vF4HZc7mIP5DS9p7aIpzl 7bJE714/4G/qee9LzQAg0Knl6airpZ8mv+y38m8GUwVWVAvYeDdW57PjwzRfx8RHSJ3t /JtqynqKfpuDuv9QOuOJIzjvdrjzzFmUbGGl9xxMxLVbVMXjHukUfV5fcij8LaVMqtzc WLqQ== X-Gm-Message-State: ABUngvfueWZ819OqzjPF3P1jqt/VOkF+86TYvJ8utIduR71vSxxEf8KXie8b2NrpWFR01SFCXQXMI2wFVg478g== X-Received: by 10.157.6.7 with SMTP id 7mr3575851otn.43.1478968064672; Sat, 12 Nov 2016 08:27:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.202.171.129 with HTTP; Sat, 12 Nov 2016 08:27:43 -0800 (PST) Received: by 10.202.171.129 with HTTP; Sat, 12 Nov 2016 08:27:43 -0800 (PST) In-Reply-To: References: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> <9a84054848086fa4c2965f93dd3b56a3@gmail.com> Date: Sat, 12 Nov 2016 08:27:43 -0800 Message-ID: To: David Walker Cc: Andrew Faulds , PHP internals list , =?UTF-8?Q?Lauri_Kentt=C3=A4?= Content-Type: multipart/alternative; boundary=94eb2c095f7a2108e405411d16e1 Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: kris.craig@gmail.com (Kris Craig) --94eb2c095f7a2108e405411d16e1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Nov 12, 2016 8:21 AM, "David Walker" wrote: > > On Sat, Nov 12, 2016 at 3:08 AM Lauri Kentt=C3=A4 wrote: > > > 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 =3D 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=3D=3D3) < 3). > > > > > > Just some food for thought > > > -- > > > Dave > > > > I don't see how you would =E2=80=9Dlogically=E2=80=9D get 3 < 3. The ve= ry 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 =3D b) && $tmp1 < ($tmp2 =3D c) && $tmp2 < d > > > > That's was the intent in the question I tried to raise with the > post-increment, as you write `$tmp1 =3D b`, to my example `$tmp1 =3D $a++= `: > > Should > $a =3D 1; > var_dump(1 < $a++ < 3); > > (expanded into numbers) be evaluated as: > 1 < 2 && 2 < 3 - True > or > 1 < 2 && 3 < 3 - False > > I could see the case for either, although, I would probably prefer the > latter, as that's what's apparent today, example with > > ``` > $a =3D 0; > var_dump($a < 1); > var_dump(++$a < 1); > ``` > > Would print out true, false. > > Sorry I wasn't overly clear in my statement. > -- > Dave +1 on the usefulness of this idea. I've always wondered why more parsers don't already support this. --Kris --94eb2c095f7a2108e405411d16e1--