Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105346 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16527 invoked from network); 23 Apr 2019 11:56:28 -0000 Received: from unknown (HELO mail-it1-f179.google.com) (209.85.166.179) by pb1.pair.com with SMTP; 23 Apr 2019 11:56:28 -0000 Received: by mail-it1-f179.google.com with SMTP id a190so22184333ite.4 for ; Tue, 23 Apr 2019 01:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KuatcQ8qB5R9P11v5ouIieXRCpqCFqefMBT1GVCeQA0=; b=TuQBG7V/OUZgFCIjvm1Twb/gw3dxxaiK0vpAJwvpbRdKrudcqbXKxQ9KJIs1kykC4X NRXCsEKsELg2IEzks29B9s4i8DwZQ45JWbFBt2+YdZIuOiyIxtM8jv4e2EbqGCfzut9v JlxC+lhD6WgZ4xsJ+ROa1hJugSSRm8xgNDjIrpTUZj24ZSuMPDavtd2ATX4yLiDMbS9h hVIjfglcx8YxtocsWGX3HTzrMACP0uRn0Ajcl/ekBE9JkThOKl5rtfKM9RBxe2d6Oqqf utif8TBszNtB59+fQDoW9f/Fwl9KEO8gASeOKgczsI6DYrl+/9Y9BVBj9MtVTcL4HRR6 XQvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KuatcQ8qB5R9P11v5ouIieXRCpqCFqefMBT1GVCeQA0=; b=XicXmDlkkWKTdTbac6QNHcNm6/9vpPN0XjVPHvZqBpWdi7DlYsVFPmVWRCdRIMnUPL eSVkYXDMH8Lv+cShZdci5S2jPRn70UhRqTHuwC/at2ZTn8YvEAfXvELWCt7w72i90GW6 fTxtO/NESds12Bjfj+F7jxhhwHOW6wAl0RPBw+/sKtJv+bgtZNyg+NmhA49mw2EIXl/C 2NL88OdNAHfcUTIMLjIhBoOvmEPXXvEd5rlzdg+6lAIo2zapBWTjm2/X+O35YOUIeiXw QBfBR0Bx4fYM1ifKGVH1pesv/uWYHsXVs9n7/QiIAA9SL34A4cW/C1b+yFr/97awoCTR JGHQ== X-Gm-Message-State: APjAAAWMi0t7ngB7VXoccJ51l4TRz/US0QluAABWSQuI21m2mKONBHyO yZN8UBKOEOw+4vLj5QydqXT0nP/FbrtMzo+6Z4o= X-Google-Smtp-Source: APXvYqwmreycccsC0uCUxWLg1ctozw2E8NBNV3LSs/ewK6tObrsjlC1hSgBLxRfeSgJcQSnHkciV9Jp1785woWrttgo= X-Received: by 2002:a24:4d8a:: with SMTP id l132mr1187860itb.70.1556009808885; Tue, 23 Apr 2019 01:56:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 23 Apr 2019 10:56:32 +0200 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ecfe0f05872ec3b8" Subject: Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator From: nikita.ppv@gmail.com (Nikita Popov) --000000000000ecfe0f05872ec3b8 Content-Type: text/plain; charset="UTF-8" On Mon, Apr 22, 2019 at 5:28 PM Sara Golemon wrote: > On Tue, Apr 9, 2019 at 4:54 AM Nikita Popov wrote: > >> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a >> deprecation and removal of the left-associative behavior of ternaries. >> Instead, explicit parentheses should be used: >> >> https://wiki.php.net/rfc/ternary_associativity >> >> This RFC makes nested ternaries without disambiguating parentheses an >> error >> in PHP 8 -- we might want to consider making them right-associative >> instead, which is both useful and matches the behavior of other languages. >> >> Sorry, but I'm a "No" on this one. > > It'd be swell if PHP's ternary matched other languages, but it doesn't, > and we have 20 years of code in the wild which has accepted that fact and > moved on. I don't see the benefit in breaking that code. Advise the use of > parentheses and move on. > Can't say I understand your position here. Don't want to change the ternary from left-associative to right-associative? I can understand that: Silent behavior changes are always problematic. This is not what the RFC proposes though. 20 years of code in the wild has not "accepted that fact and moved on". If a left-associative ternary is used, it is almost certainly a bug. If people use this structure by accident (because it is familiar from other programming languages), I'd like them to get an error instead of having to figure out why their obviously correct code is not working or, in the worse case, just leave behind buggy code. Nikita --000000000000ecfe0f05872ec3b8--