Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119824 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14273 invoked from network); 6 Apr 2023 11:53:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Apr 2023 11:53:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E34FE1804F8 for ; Thu, 6 Apr 2023 04:53:00 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.104.0.0/14 X-Spam-Virus: No X-Envelope-From: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2123.outbound.protection.outlook.com [40.107.7.123]) (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 ; Thu, 6 Apr 2023 04:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R9gzaeWIrqgRYmK32aw9xoVH9CGtJP402jtNqkP7JY5xcrUlmslgvaqTEPs08DTBBHB5UrXZBsu/L6yQQBeQqZkNHVnpy4wbxHlE6k9y5nIgRJSGy+uVspSktRh2fcmM6USo0VKPf9J+PRSZ1n/Spo5GsKVkc5UpliJcqoiAquV3wVUhrIfmdnftmJ48eb6djNIbwJcu2ibDGtYJBx52XZx8C3bi6DNYq8tM8UWzVtBdSQ97OQr3RHM+dNiAtodz1ZdfeZTx/DQldfJUw/i/JwE+657uXUMMUILyw7bNStszbYelpytDQ1E+uKTNu+Vqd0h8/han3Ii1K8bfO+f8+w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qXn1riu7WHRe34Q3FlSNSRkQh+03hZWx+7TG9jQmbhE=; b=fkzv1HscWP4DzL/XcAMqcD4t+lizSZ1jEoBxx/tw8WIUyXKQ9maaeR9NNOVbe0N2m0l1KZSoTaakU15wlJ+iSwVaXFoorPFyQ9VO2jjcv8+Ny7ePDY9O9HLey7kR+gEcPAQ2/Ch1DS87hbVHrZho8d2MSFLLPS8UeYiHOGHlqByxFSTKyulmwKIMu70CGy8fNIzBbkZZzEr2x6VaCAhp6OEKQbumx89C8nbe+UAI7LaOAaLymlngdB8Bz1GmHKPBQ/TT5OnFE1pGd7whwsMZaQ5p6Mrm0c5qrkNgW4mLZPtG7fvCBpeXI8GZBeIguhm0o7JjgkpNiZYOu1eWS+d33Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fjfi.cvut.cz; dmarc=pass action=none header.from=fjfi.cvut.cz; dkim=pass header.d=fjfi.cvut.cz; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fjfi.cvut.cz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qXn1riu7WHRe34Q3FlSNSRkQh+03hZWx+7TG9jQmbhE=; b=U5gGxP6zn6rMyGg1VT6rcXwm3XPqOOzN+PO6Q7gLNicvKsjsPuyT8jPmFWTKjQ6Q85v2lyVCnq9+HPr54WDrnwC+wDiXh88z1ishRYOKDdC3rUpN5e8Wu9G04QD9ObYQHd6POKnJi+ApHlGKPPLKQMSZlTfaE5fEQiwBiH4sy1I= Received: from GVXPR06MB8972.eurprd06.prod.outlook.com (2603:10a6:150:123::11) by HE1PR0602MB3339.eurprd06.prod.outlook.com (2603:10a6:7:1e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.26; Thu, 6 Apr 2023 11:52:49 +0000 Received: from GVXPR06MB8972.eurprd06.prod.outlook.com ([fe80::e4dc:2186:cd7d:c00a]) by GVXPR06MB8972.eurprd06.prod.outlook.com ([fe80::e4dc:2186:cd7d:c00a%4]) with mapi id 15.20.6277.030; Thu, 6 Apr 2023 11:52:49 +0000 To: PHP internals Thread-Topic: [PHP-DEV] Array spread append Thread-Index: AQHZaArhDQbwWEJJB0G6JU0PYZSu868eEkYAgAAUpzU= Date: Thu, 6 Apr 2023 11:52:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fjfi.cvut.cz; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: GVXPR06MB8972:EE_|HE1PR0602MB3339:EE_ x-ms-office365-filtering-correlation-id: 99270ee8-e00f-4c91-5c33-08db369571de x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2chvfZlRHX64YU9kSoAMzgONhcNytcN4/FKo/tAGTPDhW5E221qP1IoTDfTBxCO36lxiOg+yG4Jyl37Gu5l1mftWuQ11A+ricL4Lfxm6+ecwZ3H50nEqkmk52hwBXif566DqycBOLiB325/qEngULIvYv12sh6CZbivEdhNVOWWzCzByAVZzXPb0+NX4blyPicIlaSFMrTaLbHKsWO9ZsoFYstCuOw0XHnL5wlOMkO2wEVLn2Cv64P3874cfSYffjrNU/Tb6Xs3K/KzYO8JrnL4Aokyagu5jW1QrrvegQ3w4cfgD4RzHyA+yYJrnFcC40mLt9Pr9+O1m5uM4cs1xhx5UndgwgB2++TI6n7vZVCG/KN0mfhaQ8+McNuKdV7hcIx++b654z6OrisAvP5XFqWPAkRCoUbEWZ/dP1YxxsvuZ6V0yiBHg72YeL6amw+IlXrzbW5wcu+U9GS9J1+XD/lxjHHHw0YVMzKQR7H7EkSgq5CgdgahE6gUbZnklAykrp4agZk2qfBnxPB4jV8CC1jMrsT9h4+CUYJUu0x/+9gLer6Dr2ZvoE72WqDgXYQkA8vpDK7Ib4/dhsLfpYpi75MqGuGK/HA6TDa/N5ydS658= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GVXPR06MB8972.eurprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(966005)(316002)(53546011)(7696005)(52536014)(2906002)(83380400001)(33656002)(6506007)(66899021)(8936002)(9686003)(5660300002)(186003)(8676002)(38070700005)(71200400001)(122000001)(86362001)(55016003)(64756008)(66946007)(66556008)(91956017)(76116006)(6916009)(19627405001)(478600001)(786003)(66446008)(166002)(41320700001)(16799955002)(38100700002)(66476007)(41300700001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?BZPIAcCAVB5Uy7Wvx/0Zryj09Fj4HvEZA5L6vxufzHQDOWj9ZXONZliJ9W?= =?iso-8859-1?Q?Fm0RXQDpnKrfsf8zEf6xodSsTsx91NA4tP98ZUBeZLf7ANKzKa3j5vD3FJ?= =?iso-8859-1?Q?titBTQKxRKCKYy8oRqkKyHrs2vTiJKFsUa/EPt0pp87htzVplupmQns6P1?= =?iso-8859-1?Q?LFF8g7SF0tZAOwxjZRNdLH36gssLMJN471xBCbQ9YyKt0lwNZOCO4nuIxR?= =?iso-8859-1?Q?W48/YfyyMUdcngghwSZZYcOjb6Qsvbh3DRaqYXbQO9J8woqSny9xadYi0F?=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EDtTot6FE8EMR0jP3aVjEONBdCy9?= =?iso-8859-1?Q?6IEpaAQ2QOvbi32YbMcjjr15gvuKPpKzOV9FDK0MU01KoWtHTjEQow9TJC?= =?iso-8859-1?Q?a/v5OcfW2aQva7OErTB2SOjfct4QDGT8o9xdVfkVQwpIsTDaGZ8vpVcp5G?= =?iso-8859-1?Q?SRC/fipd11MVum+wUKR5VgnzAcZY2pQ9H4y3ImXMlN61jW3BQBRPz1gs+Y?= =?iso-8859-1?Q?43DeTMBlyCXapuQESoaIM6DWHJ44Y+5LCRBnH9GkZ7wqrTs9krvS6UNNK2?= =?iso-8859-1?Q?nuBZhDb4s4oQBG5maDYPqB/cMLT+zx8OKdNHPM7bt/Lr+RfqqpADU/vi2M?= =?iso-8859-1?Q?tNx06dhCo/pA5PWX+ub7ny5xlJ+m80EDAUkcUV1fKGSAMELEE0SzwE88IR?= =?iso-8859-1?Q?fVNv5qH64k82WbIPiNE85bjmYvBN9bHDCDO5PJ1wdoY5nN/p5D38EhICF9?= =?iso-8859-1?Q?aLsM+LYDjdZciQZ7pUY7fhLJ4CfKw35cPP?= Content-Type: multipart/alternative; boundary="_000_GVXPR06MB8972950BC5031756A8F39D5DB2919GVXPR06MB8972eurp_" MIME-Version: 1.0 X-OriginatorOrg: fjfi.cvut.cz X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: GVXPR06MB8972.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99270ee8-e00f-4c91-5c33-08db369571de X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2023 11:52:49.1474 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f345c406-5268-43b0-b19f-5862fa6833f8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f5Ayuc1ATw0tV3U45MjHgeFxLZYcwFJQmeeh4reTMVJlOC9vv1TNcogE1P5IlqrXmDSFTFaYkOY5x/idTFGivA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0602MB3339 Subject: Re: [PHP-DEV] Array spread append From: vorismi3@fjfi.cvut.cz ("Vorisek, Michael") --_000_GVXPR06MB8972950BC5031756A8F39D5DB2919GVXPR06MB8972eurp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Ilija, * Are integer keys preserved? I'm assuming no, as otherwise it would be the same as `$a + $b`. $arr[...] =3D $arr; should be the same as foreach ($arr as $v) { $arr[] =3D $v; } all other answers should be answered from this and consistency * What is the return value of the expression `$a[...] =3D $b`? I'm assuming $a after the additions of $b? https://3v4l.org/63IEU - the right side expr to be consistent with regular = $arr[] =3D expr * How does it behave in combination with `ArrayAccess`? Throw? Call `offsetSet` for each element? https://3v4l.org/v26Bh - call `offsetSet` for each element * How does it interact with references? E.g. This is valid PHP code: `assign_by_ref($a[])` (https://3v4l.org/qoJYn) `assign_by_ref($a[...])` would be about the same as `assign_by_ref($a)`, so= compile error * How does it interact with undefined/null values? E.g. `$a[] =3D 42;` works without declaring $a first. https://3v4l.org/JtO7g - same behaviour, based on the foreach definition * Is there a need for this? Given that `+` doesn't work with sequential lists and `array_push($a, ...$b)` doesn't work with strings I'd say possibly. `[...$a, ...$b]` works but requires duplication of the array which in loops can be detrimental to performance. Yes, `+` and/or `array_push($a, ...$b)` are not equivalents, and all other = syntaxes like `[...$a, ...$b]` or `array_merge($a, $b)` are longer to write and slower * One extra QA about references: https://3v4l.org/U02Cq - `$arr[...] =3D &$arr` should be compile error Michael ________________________________ From: Ilija Tovilo Sent: Thursday, April 6, 2023 12:18 PM To: internals@lists.php.net Subject: Re: [PHP-DEV] Array spread append Hi Michael > I would like to open a discussion for https://github.com/php/php-src/issu= es/10791 . > [https://opengraph.githubassets.com/a23cb565cc8acac6a33ecab5d9ee68a46f046= a1ffe215501673156e506695430/php/php-src/issues/10791] > Array spread append =B7 Issue #10791 =B7 php/php-src > Description Currently spread operator can be used for almost anything. Bu= t not for array append. I propose the following to be supported: github.com > Appending N elements to an array is quite common language usage pattern a= nd I belive it should be supported natively for shorter syntax, language co= nsistency and performance.Hi Michael There are a few questions that come to mind (there may be more). * Are integer keys preserved? I'm assuming no, as otherwise it would be the same as `$a + $b`. * What is the return value of the expression `$a[...] =3D $b`? I'm assuming $a after the additions of $b? * How does it behave in combination with `ArrayAccess`? Throw? Call `offsetSet` for each element? * How does it interact with references? E.g. This is valid PHP code: `assign_by_ref($a[])` (https://3v4l.org/qoJYn) * How does it interact with undefined/null values? E.g. `$a[] =3D 42;` works without declaring $a first. * Is there a need for this? Given that `+` doesn't work with sequential lists and `array_push($a, ...$b)` doesn't work with strings I'd say possibly. `[...$a, ...$b]` works but requires duplication of the array which in loops can be detrimental to performance. Ilija -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php --_000_GVXPR06MB8972950BC5031756A8F39D5DB2919GVXPR06MB8972eurp_--