Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114985 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40875 invoked from network); 21 Jun 2021 18:33:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Jun 2021 18:33:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B0CA51804D0 for ; Mon, 21 Jun 2021 11:51:08 -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=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail02.x-net.at (mail02.x-net.at [83.65.141.138]) (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 ; Mon, 21 Jun 2021 11:51:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id AAC13380073 for ; Mon, 21 Jun 2021 20:51:05 +0200 (CEST) Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2EebusIfCOyc for ; Mon, 21 Jun 2021 20:51:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail02.x-net.at (Postfix) with ESMTP id 79E173801CB for ; Mon, 21 Jun 2021 20:51:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at x-t.at Received: from mail02.x-net.at ([127.0.0.1]) by localhost (mail02.x-net.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6_SoG3Ee1J3Z for ; Mon, 21 Jun 2021 20:51:02 +0200 (CEST) Received: from [127.0.0.1] (178.115.52.231.wireless.dyn.drei.com [178.115.52.231]) by mail02.x-net.at (Postfix) with ESMTPSA id 39302380073 for ; Mon, 21 Jun 2021 20:51:02 +0200 (CEST) Date: Mon, 21 Jun 2021 20:51:01 +0200 To: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: <7f2da982-e29b-ccca-bddc-24ae7f4b0390@gmail.com> Message-ID: <2DF8EE9E-8B83-42C0-898D-550FF36F2943@dafert.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again) From: mel@dafert.at (Mel Dafert) >I would prefer an improved syntax for creation of anonymous objects=2E Thi= s >is something which I have been annoyed with, myself=2EI'd like to see a >simple way of creating anonymous objects with typed properties=2E Another advantage arrays currently have over anonymous objects is destruct= uring - if this was (somehow?) also made possible with objects, this would be the best of both worlds=2E (Returning multiple named values from a function is also mentioned in the use-cases of the RFC=2E) I know this works: ``` [ "foo" =3D> $foo, "baz" =3D> $baz ] =3D (array) $object; ``` (Alternatively also using get_object_vars() instead of casting=2E) But we both have to convert to an intermediate array again, and lose the type information of the object (eg=2E for static analysis), so this could = also be made more ergonomic if we want to go down the anonymous object route=2E