Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96779 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88350 invoked from network); 8 Nov 2016 21:57:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Nov 2016 21:57:26 -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.180 as permitted sender) X-PHP-List-Original-Sender: dave@mudsite.com X-Host-Fingerprint: 209.85.217.180 mail-ua0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:34944] helo=mail-ua0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/37-23587-44A42285 for ; Tue, 08 Nov 2016 16:57:25 -0500 Received: by mail-ua0-f180.google.com with SMTP id 12so158999734uas.2 for ; Tue, 08 Nov 2016 13:57:24 -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=BaUuOjOPXGt8xVDrjjD4Tvvwf1JlqUQzPnJgqLdF06k=; b=2PnsKP7FsTV7oli7JlAXUbJ49YTsuzhF1eCN6XNAX0FzZ7LoIteMu5bjsZs9SBz9od kPpfMtKAIOLYTJNTsgMvlH+ikbnIpKcd/KpMhySimKu0e8R5SQ6g7jCJehgLQkORtKp3 HvBqKJKNFUAdrNSfPpdmvV03m0f9zECZr7maNaQc4oo9UZ/3eZB8KH+rap3RMyltHmP3 7JBlqLkpHaCHRsyRdM90Js/i2UJnz9yWrupINM+irO6wijTljgkVZbgEA97wEUbLlzoB UGy0AahWJxYR57wVAhTgCzyxeJM2jC3sMVk7zC2YZdBaO3+CaEeLAalV8w58rkPjSdUx pJhw== 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=BaUuOjOPXGt8xVDrjjD4Tvvwf1JlqUQzPnJgqLdF06k=; b=mQUR865bVp43JTRmIGf9Iq7GZ7KJkK5ObKIEPKAtQ+jP87McuvZM0XOGQN2ujBnNV9 dgAoYLyA7VHM9Eb0oI/8XrgfcrjuXZIbk45hmsHdNgpm5VdF/xygMCuam66TLlH4eUzD wjS21XNH4B5Vww7eVSDQeF1qDfV5LVTT8P38j88i1nRwxhmi3N7DypGHUqSHCRZBQkYc 0VtcjuCLY5hZoBkFudP2Rt1QfeqJGeh5kMhrv8vgX2LOv6PBBgg7YDAe9jUyyRnj6g1Q irJ7Lt3mA8PLs7jmkxSVDzSKH1R8k4/ag/1n31zGkU0N5lHFfWxZIwRknQHM/mXVRG7y NVQQ== X-Gm-Message-State: ABUngveAPRHfRHReemdbTDcPcywoY6JMvqQVOqWKHXNseIeRcGfgcSBwldsfRNvo8p0NHVEPQN4Ul9UvS0ld1w== X-Received: by 10.176.69.230 with SMTP id u93mr9837786uau.158.1478642241567; Tue, 08 Nov 2016 13:57:21 -0800 (PST) MIME-Version: 1.0 References: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> In-Reply-To: <3e3180e8-e9c2-abca-5228-221f8eae713d@fleshgrinder.com> Date: Tue, 08 Nov 2016 21:57:10 +0000 Message-ID: To: internals@lists.php.net, Andrea Faulds , lauri.kentta@gmail.com Content-Type: multipart/alternative; boundary=94eb2c11c9e88f12c40540d139b8 Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: dave+php@mudsite.com (David Walker) --94eb2c11c9e88f12c40540d139b8 Content-Type: text/plain; charset=UTF-8 On Tue, Nov 8, 2016 at 12:34 PM Fleshgrinder wrote: > This requires associativity, as Python has it. > > https://docs.python.org/3/reference/expressions.html#comparisons > > The problem, as explained in the Python reference, is that in `x < y < > z` the variables `x` and `z` are never compared against each other. > This, however, works great almost always and nothing is wrong in doing > so in my opinion. > > That change would actually be brutally easy since we only need to change > the `%nonassoc` to `%left` and we are done. > > https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L73 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 --94eb2c11c9e88f12c40540d139b8--