Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96835 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14696 invoked from network); 11 Nov 2016 17:04:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2016 17:04:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=dave@mudsite.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dave+php@mudsite.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mudsite.com designates 209.85.213.53 as permitted sender) X-PHP-List-Original-Sender: dave@mudsite.com X-Host-Fingerprint: 209.85.213.53 mail-vk0-f53.google.com Received: from [209.85.213.53] ([209.85.213.53:35469] helo=mail-vk0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/1A-35596-EF9F5285 for ; Fri, 11 Nov 2016 12:04:00 -0500 Received: by mail-vk0-f53.google.com with SMTP id w194so18104974vkw.2 for ; Fri, 11 Nov 2016 09:03:58 -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; bh=FOclvgNKaUmfJzqGKFnxT2pwtaJ+B1r8lb/aHPqD3lg=; b=EPIYP72PQSB7rb2KXxtDce2Q1vew6yVELDmvaP+1cetBD3jm+W0vuRU/SDrnWO1jwU PAcEIeBICv8M32V7vDEOzxM4Z/enmLtbBFJd3OuqyeU2EfIyDAqk0oi83ecObRfR2MBF 4oFsK/DfthPj7YhHlKBYfGTIxQYigNqZBrmaZyYgtWkDBalFypZrQ7XPNVOHelEjAOp3 uy0wtywU+PrA+Zb7vk7MxQ3BHQkVtjeRTcRmZifEIdmXzrjUZXVdoVinyZ7Z2AkQ4hac tx5HEF8mCERQLEKSf8Sw0qZInPuoKpC2kjF3D3wYWjr/qrj2owqn4LsyT7JiltmAeiyv r/eA== 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; bh=FOclvgNKaUmfJzqGKFnxT2pwtaJ+B1r8lb/aHPqD3lg=; b=SN6bm86mGxG+/gbujyb7gZ6KhJspkq8wPEDW5RniIrv1Uh4ZNYQyJbWeiGN08NZbkj xEfqH82udfGn0se/K/2gI9stFzzitMHIIqIzRPhHr9NSQWgv9YrAVkioy7nhHgSVEIAJ CJ8HnUj3awxmGprBlx1cAX2fPfR66FiYPHlV9QIhGNySOH0ENp2gFlm0CBZSbuevaCiv lQRRHg3WUvOC2oE9iDtuot8fCCbTU1uHD3J549yRMSGLUoVwJzVEEJ7WI+Nn4bnKMoXe exJnlWXts46VEMZdBEA5jYvbram8CaG4Jcoon7/baQFyZSUMO3AkNJu2Cj3AP6uHafo4 AJ3g== X-Gm-Message-State: ABUngveKD7Xox7YpjdJiG9clOcUmGPbAwXj7A3uQPg8PM+/79fRuKTyt7rWla39NjrRDN74RgXC4v6asUQo2qw== X-Received: by 10.31.6.197 with SMTP id 188mr2028114vkg.19.1478883835439; Fri, 11 Nov 2016 09:03:55 -0800 (PST) MIME-Version: 1.0 References: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> In-Reply-To: Date: Fri, 11 Nov 2016 17:03:45 +0000 Message-ID: To: internals@lists.php.net, Andrea Faulds , lauri.kentta@gmail.com Content-Type: multipart/alternative; boundary=001a11440feeacfe11054109793f Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: dave+php@mudsite.com (David Walker) --001a11440feeacfe11054109793f Content-Type: text/plain; charset=UTF-8 On Wed, Nov 9, 2016 at 12:48 PM Fleshgrinder wrote: > On 11/8/2016 10:57 PM, David Walker wrote: > > I don't think that alone allows the chaining of comparisons. I'd have to > > look closer, but it'd seem to me that zend_ast_create_binary_op > > (ZEND_AST_BINARY_OP) evaluation might need to be amended as well. Seems > it > > eventually calls a `op(zval*,zval*,zval*) so the evaluated end of: one op > > would be a true/false, when comparing against another boolean op. > > > > Regardless of implementation, the core question you raised was should > > something like it exist, I'm still a strong yes on that front. I'd just > > promote introducing the left precedence and allowing the arbitrary chains > > of comparison, rather than just a single interval comparison. > > > > cheers > > -- > > Dave > > > > Yeah maybe not that easy but also not too complicated if we add > associativity to the mix. I am open for both variations and could write > up an RFC with a vote for both if desired. > > Not sure if I find the time to look into actual implementation but I > most certainly can try. > 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 --001a11440feeacfe11054109793f--