Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111159 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70389 invoked from network); 23 Jul 2020 18:41:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jul 2020 18:41:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 835A2180556 for ; Thu, 23 Jul 2020 10:36:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from v-smtpout3.han.skanova.net (v-smtpout3.han.skanova.net [81.236.60.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 23 Jul 2020 10:36:26 -0700 (PDT) Received: from [192.168.7.8] ([213.64.245.126]) by cmsmtp with ESMTPA id yf8qjZuKyxDlhyf8qjUJVW; Thu, 23 Jul 2020 19:36:24 +0200 To: Sara Golemon , Nikita Popov Cc: PHP internals References: Message-ID: <9f990f47-c634-9ea0-e501-504ae1aec1ca@telia.com> Date: Thu, 23 Jul 2020 19:36:18 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-CMAE-Envelope: MS4wfN+dQjkvvWlY0jsQVSWJSgEpyCcq0eP1E0psG7czIXeFrHsAwbrSSPd8Ld0KiW9hvbKQY5MC1pfOKO057BRP1bMGzo/u/ZG8D63RBTvMJO5/mE/m9pp+ scky9OsFhhnvWKmW4+lsqluHDFdEv4MI9s0GuxdRHpKZDi6AbxbhUdaWfZNsqb+ikxRtA3KQAvgzhSvTjVAeo9vmXfYUJ4jZaBLXufO7tUhGFZT1SWEmRGXm s9wqkZowAjVS6Jytgetdng== Subject: Re: [PHP-DEV] Ternary associativity From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2020-07-23 kl. 17:26, skrev Sara Golemon: > On Thu, Jul 23, 2020 at 7:26 AM Nikita Popov wrote: > >> PHP currently has an incorrect right-associative ternary operator. In >> https://wiki.php.net/rfc/ternary_associativity the use of nested ternaries >> was deprecated, and was supposed to become an error in PHP 8.0. >> >> Concurrently with that proposal >> https://wiki.php.net/rfc/concatenation_precedence made a very similar >> change to the concatenation operator precedence. The difference here is >> that this throws a deprecation notice in PHP 7.4 (same), but changes the >> behavior in PHP 8.0 (rather than making it an error). >> >> This is a pretty nonsensical outcome, in that the same type of change is >> implemented in two different ways. I think it would be good to handle the >> ternary change the same way as the concatenation change, i.e. make >> ternaries use the correct left-associative behavior in PHP 8.0, rather than >> throwing an error. >> >> Disagree. Consistency is valuable, but the overlap of misusage is > different. > > A stacked right-associative ternary will still give a "good" result in the > sense that it's reliably reproducible and meaningful in its output based on > being written for right-associativity. > A concat mixed with other binary ops (e.g. math ops) will NOT typically > give a "good" result since the string being contacted to the numeric then > having its math op applied will result in a nonsense answer at best. > > It made sense for the concat change to favor "fixing" old code in ways that > doesn't apply to stacked-ternaries since a similar "fix" there will more > likely be a break. > > Strong -1 from me. > -Sara Would it then make sense to have it as compile time error in 8.0 and make it right-associativein in e.g. 8.1? OTOH, when looking in RFC on top 1000 affected composer packages it looks like having the change in 8.0 might be a way forward... r//Björn L