Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18763 invoked from network); 14 Dec 2014 12:02:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2014 12:02:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=happy.melon.wiki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=happy.melon.wiki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.173 as permitted sender) X-PHP-List-Original-Sender: happy.melon.wiki@gmail.com X-Host-Fingerprint: 209.85.217.173 mail-lb0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:40460] helo=mail-lb0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/10-17520-64C7D845 for ; Sun, 14 Dec 2014 07:02:14 -0500 Received: by mail-lb0-f173.google.com with SMTP id z12so7915352lbi.18 for ; Sun, 14 Dec 2014 04:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=LRfUZRY9u9Otrwls3j/u7G6oaudTL/MXOFXA+loq1NU=; b=eo0P2wRCK93HahRxXa4j9zzisjcrHlVNFCQWucu/CkSX8OE/p+SLe6zB+hdig1VnNb oF+w3jMIHSGMf7tmu8HxNIxEEwrz7HCcVyAj5TrNvqr902XS+6sRWVlYOYSK9oP7iCX7 EcYWH0H0yOZZd2Q/ekQbNbGWpJxnZ0NdZ6MdD+k9OUkFX5kN36FcPfPzaPKwUql81heS uroVVWfTC4XLfLqV4c+W5oZLqtZkCBab106c4SbKZQpHBz9Xe9G1FS6AnEAxwKVFZv+C bL247qRsZZpzGwupSsmebvmTojiv4l/D5+KgkT4MHon3AyaRgsHr48ZwGIi8qhLPLn8+ RGIQ== X-Received: by 10.152.28.227 with SMTP id e3mr25278804lah.54.1418558530810; Sun, 14 Dec 2014 04:02:10 -0800 (PST) MIME-Version: 1.0 Sender: happy.melon.wiki@gmail.com Received: by 10.25.170.2 with HTTP; Sun, 14 Dec 2014 04:01:50 -0800 (PST) In-Reply-To: <548D494B.8010901@gmail.com> References: <548D494B.8010901@gmail.com> Date: Sun, 14 Dec 2014 12:01:50 +0000 X-Google-Sender-Auth: xHbZRlaWRdhuDZNHp0CKetf2ksE Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=089e0160b7ce527855050a2be52b Subject: Re: [PHP-DEV] Fix incorrect ternary '?' associativity for 7.0? From: happy.melon.wiki+gb@gmail.com (George Bond) --089e0160b7ce527855050a2be52b Content-Type: text/plain; charset=UTF-8 On 14 December 2014 at 08:24, Leon Sorokin wrote: > > On 12/14/2014 12:51 AM, Levi Morrison wrote: > > > While I think long-term this would be a beneficial change I think in > > the short term it's quite a hurdle. > > This discussion will be identical whether we wait till PHP7 or PHP9 in a > decade. The longer this change takes to make, the more code that will be > mis-written to rely on the current behavior. If any long-term benefit is to > be reaped, now is the best time to do it - every future major version will > have a harder justification to make. > > > There is definitely code out there relying on this behavior and > > changing it will result in the worst BC case: it will not fail in any > > way but will instead act differently. > > There are also definitely IE5.5 users out there and websites that rely on > IE5.5-only features, but the actual numbers matter. There's no doubt that > somebody, somewhere is going to have broken code because they wrote it > without reading the docs that recommend against it or without understanding > how it works, or upgraded without reading a migration guide or realizing > that major version upgrades do make breaking changes (more often than not). > These people do exist and they may curse PHP rather than themselves and > leave it forever; the desire of the core team to retain the maximum amount > of these users is puzzling. The change under discussion will not be causing > any sort of mass-exodus from PHP, the ecosystem will not collapse and it > will not be the heat-death of the universe. It will be removing a > long-discouraged behavior and bring expected uniformity to a common > construct that has differed for no good reason from other languages. > > There's plenty of room for a #5 on the already non-0 list: > https://wiki.php.net/phpng#incompatibilities_made_on_ > purpose_and_are_not_going_to_be_fixed > > In my opinion, chaining or nesting ternaries at all >> should be discouraged; changing the associativity doesn't change the >> fact that they are more difficult to follow and more error prone than >> using different constructs. >> > > I would disagree on this point. Just like there are cases where a large > switch/case results in more readable if-elseif chains, long conditional > assignment chains can serve the same purpose, granted you space them > appropriately. I would even go as far as saying that with proper spacing, > they are more readable than the 'if' or 'case' blocks that would need to > replace them. > > -- > Leon Sorokin > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > If you wanted an upgrade path that was not Evil (in the sense of not introducing subtle and hard-to-diagnose bugs), could you not change the operator to be *un*associative in PHP7? That would effectively just make concrete the discouragement/deprecation that's already in the documentation, and would produce irritating but very visible errors for anyone still actually using this functionality, as well as making them alter their code in a forward-compatible way. Then if you want to think really long term, plan to implement the 'correct' associativity in the *next* major version. --G --089e0160b7ce527855050a2be52b--