Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112082 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83749 invoked from network); 20 Oct 2020 23:36:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Oct 2020 23:36:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A49E21804AA for ; Tue, 20 Oct 2020 15:53:41 -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.0 required=5.0 tests=BAYES_20,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 NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003073.outbound.protection.outlook.com [40.92.3.73]) (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, 20 Oct 2020 15:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3aBcWqsR/g/epgvK/jgKBVyfnJyaFGOx7yzOXSNL40d6lSym0R92ncGJDz8NyqQwtP86Hs9nu9L5Lqf00eYHJm1P7yTiiiS2b3G+xP/MRO3099VoAEKzfVpHNeFZ0uaCwB8q71zyFRgJdxCDvWt1Zg5IYzEUO9duihXO8Vlmh5Uvg5oJakV9AgvldJi1+UQmrKU3lWKcADDpW170fftVaJBKhcew3C0XzZ+cTEQzL9uhIhCGIX0Nv8cjox1O9ig8qc2ZF3Tnf7FFz01+YgYC7FYVn7uypPcK8OAHxWYNvpoXwBS4CmcuJmoMCvKMX5YfxiP52MgPaf5FyDqMDcXNw== 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=VgvjwItCTi0wGSnt5vWEoxXNrPaAgMen+JptsuASY6M=; b=gsFvOuGkSWH1M4OeSUWuTMf/3qG6XGbLCG4lLR7ZX5s3HyrZb85LRGHhzgedGw6MSqbGbtmkx1+xIS0Me/AMnsGenIG8J3c+Qb6qZ94A5iVkUcDgrUKnj+WWEOV8L+3Ii2RW7EjUjmdSstGFGN02CUSvcByyHb/YUgweQRdK75YbLzLleVb6Pn1+l2nY18oZaHM6+E6oKio2MPUsfHziDFUH5j9A9UIVLnIn72Ipa+GGtl2vzurTJeTzumgjaLvQe0BFzqiT6pHWCPSZgmH2/0iisyDyhiy/z7uYV6T6iXdua8Uou9RFiGpVkLCKIZ+BGK+wLKcBINHUCIlP/UJJRA== 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=VgvjwItCTi0wGSnt5vWEoxXNrPaAgMen+JptsuASY6M=; b=U/9hJlw27CSI4sCrJuFh9Ma6KQRGmgG0dd6xsmPl77yjsZqa6xPBm+ZaZbnTi6zfnTwM3HUuBoH5rgxYC6a3OrIM86/sRhoWVWyaz9mFM6meMS1ckmczHktsuAHqFypU9iVBgThirsRQswLEFMqk7lRX9b/5OhlBJ/0ke031YpsHELgGRm14pfI3mOIYFVwcNMWHFtJneIxaQ2GJQ96II/YDCJ4FgWokl2LFrmQCq/pRoVs9PqVxh80OVRZ7r+UE0sD6p+7OQu21K7xci2DO+mZysQMI4yRtMrTF40neGcmcJ7SgRhTqGg7IMODJZ+ChOuknu5Pf1Ya0lEKKYg5/pw== Received: from CY1NAM02FT032.eop-nam02.prod.protection.outlook.com (10.152.74.60) by CY1NAM02HT010.eop-nam02.prod.protection.outlook.com (10.152.75.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Tue, 20 Oct 2020 22:53:39 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e45::41) by CY1NAM02FT032.mail.protection.outlook.com (2a01:111:e400:7e45::440) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Tue, 20 Oct 2020 22:53:39 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00%7]) with mapi id 15.20.3477.028; Tue, 20 Oct 2020 22:53:39 +0000 To: "internals@lists.php.net" Thread-Topic: Is there any interest for object constructor shorthand *just for stdClass* Thread-Index: AQHWpzItYgqnRmEigE2pFjddTST5Ow== Date: Tue, 20 Oct 2020 22:53:39 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:CEFDC944E9F55C3BFAFE871F32116929E7DDF2517B496B569203C83D7F86E16C;UpperCasedChecksum:FE7F0A9A94E07A0B2176001DB3701DF74D1A38C996914581DB7C0F3DDE20B78D;SizeAsReceived:6857;Count:41 x-tmn: [SAFjE4UmakDVjZGbVGUmpiZQLu1WA3O1vU78GT3BfcSh+WR8zcQl6u3eU4x+Bt/g] x-ms-publictraffictype: Email x-incomingheadercount: 41 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: cf4c9bb4-0ffd-407f-cab4-08d8754afc73 x-ms-traffictypediagnostic: CY1NAM02HT010: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WPPnI9s1HWdFWybeHtoL24+/C7/lYycFZBsVu3qLGlb62H7m8aroZPrfRwES38TMkG3Svx3GMIDkjS8zoVG0POR5NkxnMbs+PvaOrJqQ+PUwsTtAfXTqpsl4wVOjwx/arsExmct1M4v4VGlFQ9LQzeHundZx/PreGgWn4KWe5McJ4y6171R4xIADsgHTpF4ZBb3QDLYr4j9A+eZ0YsHLWkMMfMKBdj+VizMQgNE/6PH1mYcjfu3WI26pgCRSfFw5 x-ms-exchange-antispam-messagedata: haXMIhayDLBmlc3Up7ESN8MZ979eesnPsyX+qak5E+g8f+4TbS7QGzm1MJquUeBZD+All35PVTKeEjPa4+AlVi1W2cGnNPpBZ2Cmi+jIrThFF2DKxIHhcE2i//8jtye4BghpT36c+6HMOD/KWSSM2qcDArIfdtpkhWyU70QXTjl+AdVpSNR7LnT4xGka9NOgbdqRxo1vssW06iRawUHJgg== 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: CY1NAM02FT032.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: cf4c9bb4-0ffd-407f-cab4-08d8754afc73 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2020 22:53:39.5922 (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: CY1NAM02HT010 Subject: Is there any interest for object constructor shorthand *just for stdClass* From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= e.g. `$x =3D object{key: object{'escaped-literal': $v2 }};`=0A= (equivalent to `$x =3D (object)['key' =3D> (object)['escaped-literal' =3D> = $v2]];`)=0A= =0A= For example, in JS, non-string key literals are surrounded in `[]` to unamb= iguously reference them.=0A= Here, that could be `object{[$key]: $value, [MY_CONST]: $other}` - but `(MY= _CONST)` would also work=0A= =0A= - https://externals.io/message/52990 was mentioned 9 years ago but would po= tentially conflict with future block expression RFCs=0A= - `object{key: $value}` is suggested here for similarity to named arguments= =0A= =0A= Benefits:=0A= - Shorter and more readable code - casting an array to an object is an unin= tuitive and potentially hard to remember=0A= way to create an object literal=0A= - Make it easier for users to use objects for generic associative data inst= ead of using arrays both for lists and associative data,=0A= in situations where it may result in more usable APIs=0A= =0A= For example,=0A= =0A= ```=0A= $x =3D new stdClass{};=0A= $x->prop =3D new stdClass{};=0A= $x->prop->a =3D $a;=0A= $x->prop->b =3D $b;=0A= // Could be shortened to=0A= $x =3D object{prop: object{a: $a, b: $b}}=0A= // $x =3D (object)['prop' =3D> (object)['a' =3D> $a, 'b' =3D> $b]]=0A= ```=0A= =0A= This proposal is only for stdClass - there was not much interest in https:/= /wiki.php.net/rfc/compact-object-property-assignment =0A= and the combination of named properties and constructor property promotion = helps with the readability of other classes.=0A= =0A= Thanks,=0A= - Tyson=