Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118987 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 164 invoked from network); 8 Nov 2022 17:09:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Nov 2022 17:09:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9F811804F8 for ; Tue, 8 Nov 2022 09:09:32 -0800 (PST) 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, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29169 217.70.176.0/20 X-Spam-Virus: No X-Envelope-From: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 ; Tue, 8 Nov 2022 09:09:32 -0800 (PST) Received: (Authenticated sender: come@chilliet.eu) by mail.gandi.net (Postfix) with ESMTPSA id 8AD211BF209 for ; Tue, 8 Nov 2022 17:09:30 +0000 (UTC) To: internals@lists.php.net Date: Tue, 08 Nov 2022 18:09:29 +0100 Message-ID: <12089969.O9o76ZdvQC@come-prox15amd> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Destructuring Coalesce From: come@chilliet.eu (=?ISO-8859-1?Q?C=F4me?= Chilliet) Le dimanche 16 octobre 2022, 23:11:05 CET Bob Weinand a =C3=A9crit : > Hey, >=20 > I've written a small RFC about adding coalesce ability to list() destruct= uring. >=20 > This should enhance the ability to easily, concisely and readably destruc= ture arrays with default values. >=20 > https://wiki.php.net/rfc/destructuring_coalesce >=20 > Bob Hello, I voted no as the syntax is too confusing. It reads as if coalescing would = happen on the var while it happens on the array value. It means $a ?? 'value' would mean something different when in a list contex= t. It also looks wrong with keys: list("name" =3D> $name ?? "unknown") =3D json_decode($json) ?: []; I would expect: list("name" ?? "unknown" =3D> $name) =3D json_decode($json) ?: []; But event then it looks fishy since "name" is a key and "unknown" is a valu= e. I understand the need but I just can=E2=80=99t see a good syntax for it, an= d the one chosen in the RFC sure feels not good enough for integration. C=C3=B4me