Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96763 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79065 invoked from network); 7 Nov 2016 21:51:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2016 21:51:34 -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.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:35690] helo=mail-ua0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/A0-05967-367F0285 for ; Mon, 07 Nov 2016 16:51:33 -0500 Received: by mail-ua0-f182.google.com with SMTP id 12so131675757uas.2 for ; Mon, 07 Nov 2016 13:51:31 -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=P3X5cHLLYvhjt3Btxi+eBJixdqlkmqVFmvImL1V82Hc=; b=UTX1nN/EHAxIpGcptwz4F/RPSbFx0IbXXQw0cBmkiN0UXruyKCaTdZa18rDFeFufKd 079bWZqdx1wQUCTMVJ/pdHFQk3jrwLKKAYLuwBm2QQs6cPr5l2lQ0PGSiDQtmrpHR2IW /K0R0Kt1oZgXEf1wbUrEvw3R1Njt+6Kd4Ldn7JUXeciWQB8mQVtqBw2N2/XbIAj3mklX pfxdP+9nmtg+iUCaKZRZARdsN7kDtbO0Ihj16Z7oE3/omiLXxX9zKpiPrQZ7TuzZv6he JGBAdJx0JjrfbZd5rm/f3xTtweeN/NlmQuqLmo11VYMofyXXxykNdlJB1oexu0N6lWRc aylQ== 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=P3X5cHLLYvhjt3Btxi+eBJixdqlkmqVFmvImL1V82Hc=; b=EbrptFvSR1Sw0Efpu28pTniXuoZGiL6MgSKDa22FYa2TcbzVjAE4CDzk4//TAJBI2B qYr0nwL7W8JhSs3t0dlWVItZTlYx3nS8je5objwdtiE1Io5XM0Z8dEwsRiPqWSJsgDKZ JbIgE1YbM86Y/EIyi/NdCMBMfOO0EiMHcMhjCByumVxf3apvTd4NzQqJW+R1fupxhWu3 O8PZ4p5BhtHHxv8E9WTFdhGv9GwBtqZEwKJ44Yfph//mXH5PP0c4nqZWAnMtugFABdRF FWlxO3eUy6Gqpb7bp7nFs0+v92fPhnaJi618u9T8ypSZDMWt1wMisYQHh3waoMvvEf3Y N1DQ== X-Gm-Message-State: ABUngvfNYZyQQpSSQ0gf4oPbq5WgcfpbaFvtOUHAGkdGPiI0BoJMwPvo0sILYXBxJBnctZeMZ9IZxf4uVuD0wQ== X-Received: by 10.159.36.108 with SMTP id 99mr6140996uaq.124.1478555488840; Mon, 07 Nov 2016 13:51:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 07 Nov 2016 21:51:18 +0000 Message-ID: To: internals@lists.php.net, Andrea Faulds , Fleshgrinder Content-Type: multipart/alternative; boundary=001a113d1268b180070540bd0648 Subject: Re: [PHP-DEV] [RFC] Interval Comparison From: dave+php@mudsite.com (David Walker) --001a113d1268b180070540bd0648 Content-Type: text/plain; charset=UTF-8 On Mon, Nov 7, 2016 at 1:38 PM Fleshgrinder wrote: > Hey guys! :) The first one should definitely be an error since it makes no sense. Sense be damed ;-) . I'd attribute it to an identity of sorts (if it was to go all out with comparison chaining). Yes it makes little sense, in practice, but the truth of it would be the same. > The following will also result in an error: > > ``` > if (0 < $x < $y < $z) > ``` > > We are only extending binary to ternary for <= and <. Of course it does > not matter whether any part is constant or variable (hence you can > exchange any and up to all variables in the following example with a > constant number expression): > > ``` > $x <= $y <= $z; > $x <= $y < $z; > $x < $y <= $z; > $x < $y < $z; > ``` > I realize that my comment, and question were going a bit off-topic with going on about the chaining of comparisons, but I'm interested in it more because I wonder which would be harder to implement. It would seem to me that it would be harder to implement a means in which you only allow one additional layer of comparison, rather than abstract chaining of comparisons (<, <=, >, >=). As Andrea noted, python does allow for arbitrary chains of comparison. I'm not exactly sure how precedence would work with comparisons, rather, as I see it the comparison would need to be expanded such ``` if (0 < $a < $b > 10) ``` would be akin to ``` if (0 < $a && $a < $b && $b > 10) ``` I, of course, am only projecting a potential syntax, and I'm no yacc/ast aficionado by any metric, but it'd seem to me that it'd be possible to convert some stack of elements here into a recursive comparison. -- Dave --001a113d1268b180070540bd0648--