Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111153 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45247 invoked from network); 23 Jul 2020 16:31:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jul 2020 16:31:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E23C31804F2 for ; Thu, 23 Jul 2020 08:26:33 -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=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 23 Jul 2020 08:26:33 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id 140so3491084lfi.5 for ; Thu, 23 Jul 2020 08:26:33 -0700 (PDT) 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=Br6pMYzOljxJ7MmPyJsZwQgR+k+XKlMJK/I+j6INf1I=; b=KeRyJ/vaUZKNwMt0RXVsSVd/G38k07gaHmIShsqKMk9FRBBbuEvSlLca4DKRJv6r6U jaQy6/GdqDeInZsfneEciLKIGp7uIjeNgNP6YYOyvhVVnXEv11cf9aEn2s5yBfhdKYLd ZCJz8VfXjHot2jKE967g2J6hy9sYEOZ1NGcD9+3yy4sX7TO4lhBArVqvLL/ZUk5XYqB5 2d9GwS5zZMA9T36sgCzWXuCvKd+X0UP6BSTdK9ymQMj+8jHpGF/EtwSXEO7wJYdbpopj UisjaK1tGVHpyqIO1ARUNE5wjfOYnh65p4dtk3IwIl9B2cB9KmrFD4/6hsZ3VBtVRLOg vSeQ== X-Gm-Message-State: AOAM533Iri3S/6F4YJG1zs1xkoeVnleTdJVqqQVrpTaDRexbjRNZx4Nb s/a0rkl/2cDiX/oasbuf2FD17/QnXTGwaso+5vEvWg== X-Google-Smtp-Source: ABdhPJxPbuEFmbQxt17yJcFXIpdS2HUnfeSrbW/x3+/DaKCmElhGc/z0A7s6maBuw6VnHw5NmHie72B9jGUxvkWszbs= X-Received: by 2002:a05:6512:20c1:: with SMTP id u1mr2531708lfr.17.1595517992128; Thu, 23 Jul 2020 08:26:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 23 Jul 2020 10:26:21 -0500 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000027697d05ab1d7be0" Subject: Re: [PHP-DEV] Ternary associativity From: pollita@php.net (Sara Golemon) --00000000000027697d05ab1d7be0 Content-Type: text/plain; charset="UTF-8" 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 --00000000000027697d05ab1d7be0--