Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115000 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85315 invoked from network); 22 Jun 2021 00:31:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2021 00:31:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 101F41804C9 for ; Mon, 21 Jun 2021 17:50:02 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08olkn2095.outbound.protection.outlook.com [40.92.45.95]) (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 ; Mon, 21 Jun 2021 17:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zjfp13lJ4SzhrPekQA/E3+6GmKnZRubQzAfpx0XL2koe3rbnLyE69g4p6chzhbf/3CrKw/AkmdEwxEihr6D7Fd8fK95W+F1MOnR5vAr/8F6x0FKDK6HG8pzoa6OftAbC2eVAhIQCXgA+HIKAUvjTHqBwJbA1CZ0qALWv1Jurh9AR8SC57AEVy9OGBWeX+t8c9P30/47z37mnuIN40FFqKMz7BpEL1/II4+JGcH5AgdN06cx1AR9vwfSfD5jswXDrneYCAYFkoxTkkXsNc5OG4ErPK7IHlpOmALu7xDwzvob1kGXeik+i7RUKvIw90PgYzgs+vi6IUUipy5U4Wp5EIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ejIL66tEIoVUkQOH0FV08K7EqKpvOQMjKP+KsjG/dAc=; b=mjQEYMN1T6G1wt2G4aZygXYAl11kXqAOfJewKM3fkwNPPrAI5u12koHoSTiXElnUSbOn0fvQQZcjn4YMXlRe/m9aeV9gaBHD23oXICrZ3/+O+mJNSxMSlkHOdNZpa015mM4pZv4VJRjJ6j7/0mCifEmKQbEpPqYJWoa0t60Vx6sXy+Au8fQ39uPB92daEMRo1jQw+QC1BVzTTxwIoWaVfhmXsFqzrEefeGpWC3gw+Xh/X2tkq3B6YlC1CYTG8UoibmnONH0a8QgM4Z/mJK6PrQtVaPPlakaDndzi0N/ekHz8QNiOaRHZhw+6W0T2+dZIIJUfVhhrO8lreNM3uPM0yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ejIL66tEIoVUkQOH0FV08K7EqKpvOQMjKP+KsjG/dAc=; b=NmL42YukPrvaWNvvh61dm0hFtnJlGlxoSvglIRz85nkUU7LdVPSzNb5hcDf9e1n47nRa7leZRuz9ByTPzuN/dRZ94nNxLpB37n8n1ECkxqGXMbjdjIFvHmtRy5oIAx1O8XdT3XJ2Ks/umigNaryyIhc87quTjgS5Y30Fo03cle9AIhDr0ES7Q5cXdlWknpzO0AeIDqW1q4lamNgEkW3jpoMObPgRwwaKrQadOdjpXJpPgPfnOczSHEyIidgbr6jQgD0t+h0G1rPCoGN7No6F5R1q/jGldGc8y169x4ppXwXTQjgCW6WwiKeVaD8q/RO///onhY87Iz+IR9UxoZaOFA== Received: from DM6NAM04FT005.eop-NAM04.prod.protection.outlook.com (2a01:111:e400:7ea3::50) by DM6NAM04HT132.eop-NAM04.prod.protection.outlook.com (2a01:111:e400:7ea3::385) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16; Tue, 22 Jun 2021 00:50:00 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7ea3::49) by DM6NAM04FT005.mail.protection.outlook.com (2a01:111:e400:7ea3::239) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16 via Frontend Transport; Tue, 22 Jun 2021 00:50:00 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::20ed:6cd1:4fe2:eea7]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::20ed:6cd1:4fe2:eea7%3]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 00:50:00 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [PROPOSAL] Bare name array literals (again) Thread-Index: AQHXZryCJm/mj5rNokqkQmATCwMJ5qseudGAgAAEYYCAABEXgIAAXReK Date: Tue, 22 Jun 2021 00:50:00 +0000 Message-ID: References: <7f2da982-e29b-ccca-bddc-24ae7f4b0390@gmail.com> ,<2DF8EE9E-8B83-42C0-898D-550FF36F2943@dafert.at> In-Reply-To: <2DF8EE9E-8B83-42C0-898D-550FF36F2943@dafert.at> Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:A6CFEFD8DE5807752E7D2BC36FA83B99EF09631D6686C9A829F7F500BA82D8BB;UpperCasedChecksum:2E8124F28E279630FA593A73FD5AD43F7FCE8C715B8715893856453BEDA5A6C5;SizeAsReceived:7221;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [j/hDfLSgjIhc36Yc1HmkIg93WhPqUol5sn8k6p6ESGJHxauW/L1hjrRW+1bpHL4/] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 2317548b-1c61-43f1-5792-08d93517aa2c x-ms-traffictypediagnostic: DM6NAM04HT132: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: e1GMNuxJCCXb6KmfiuCwt1iYMnkwhB+TLcla7PIknPxw5HAMJit5M5S1IxWbJ6jQ2hUf4KAZ0gTnHyGK+UqXQW2xXdOyK+fOsIrZTuUbeHDjEqenyuf6PegeGWFNvHEyDgqeT8BOOi0T2Qdb8xtRDu7QmvrMZSC4XOu/m3oXPFbKsb9ZCwQU+FlEquxSnMKsic+9AmLd4JvViMrW3S3MOQUwWJOHdjxRPmOmr22h/k3aU4wz5V4s3zGcStwqEn5WFGg0D9YsoaNJMXfbwpN1v1VSkBy46TuvDe+/Ay7oX/bTI16nFv29qs7GwTmUP9wwOuZ+h5N6HC5+R3sZEDnmkDf/YTmGAJaTQEe0o0spHQ4hdrvTOI6TYSCl3Rre+AS0Q0YMnFDSSuIzvHTf/uCxt64TbMgZUBGd7SriWsW7fDLLfwJeyHBwc8sogNIhN95Q9Hug5/GtghlTj9Fy+ZJrJA== x-ms-exchange-antispam-messagedata: lN6FQJlN46yzOaXXWHxNoGG+pBbDe0iTiPRFwbaXRCdhpvpL9kRKLSPYE+gCuMoaF+ak2thHJCUjYLzc4SzjbNf6OnI/47lm8TYWhrXSs7aGO5cydelfxRVr+hcWy41ZUaDUDlzBwlSooN95RmxW7KBxVSYZ5U/AmISGKaa9RRi/McsMBEife8q3gd2SN4kb5fB7Nd5sKV6mpwv797XNtA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: DM6NAM04FT005.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 2317548b-1c61-43f1-5792-08d93517aa2c X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2021 00:50:00.4408 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM04HT132 Subject: Re: [PHP-DEV] [PROPOSAL] Bare name array literals (again) From: tysonandre775@hotmail.com (tyson andre) Hi Mel Dafert,=0A= =0A= > >I would prefer an improved syntax for creation of anonymous objects. Thi= s=0A= > >is something which I have been annoyed with, myself.I'd like to see a=0A= > >simple way of creating anonymous objects with typed properties.=0A= > =0A= > Another advantage arrays currently have over anonymous objects is destruc= turing -=0A= > if this was (somehow?) also made possible with objects, this would be the= =0A= > best of both worlds.=0A= > (Returning multiple named values from a function is also mentioned in the= =0A= > use-cases of the RFC.)=0A= > I know this works:=0A= >=0A= > ```=0A= > [ "foo" =3D> $foo, "baz" =3D> $baz ] =3D (array) $object;=0A= > ```=0A= > =0A= > (Alternatively also using get_object_vars() instead of casting.)=0A= > But we both have to convert to an intermediate array again, and lose the= =0A= > type information of the object (eg. for static analysis), so this could a= lso be=0A= > made more ergonomic if we want to go down the anonymous object route.=0A= =0A= Ideas for syntax:=0A= =0A= There's `object(foo: $foo, 'hyphenated-key' =3D> $key) =3D $object;`,=0A= but that would require making `object` a reserved keyword, and it currently= isn't one.=0A= =0A= - I had suggested using `$x =3D object(foo: $foo);` as a shorthand for `$x = =3D (object)['foo' =3D> $foo];`=0A= at some point. Feedback was negative for largely unrelated reasons (stdCl= ass in general). https://externals.io/message/112082=0A= =0A= `object{foo: $foo}` seems similarly unambiguous by requiring at least one p= roperty but would also require a new reserved word=0A= =0A= Or `({ foo: $foo }) =3D $object;` - On second thought, I'm against that - t= hat is very likely to conflict with possible future proposals to parse bloc= k expressions.=0A= (e.g. getting parsed as a label for a goto followed by returning the variab= le $foo.)=0A= =0A= `list{ foo: $foo } =3D $object` is unambiguous, I guess=0A= =0A= `(object)['foo' =3D> $foo] =3D $object;` was another idea but that wouldn't= even work.=0A= It's already valid syntax that is parsed as casting an assignment to an obj= ect.=0A= =0A= `->{'foo' =3D> $foo} =3D $object;` may be parseable but doesn't make much s= ense.=0A= =0A= Thanks,=0A= Tyson=0A=