Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119820 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71866 invoked from network); 5 Apr 2023 23:39:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Apr 2023 23:39:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 37EB11804D7 for ; Wed, 5 Apr 2023 16:39: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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 5 Apr 2023 16:39:40 -0700 (PDT) Received: by mail-yb1-f171.google.com with SMTP id n125so44468405ybg.7 for ; Wed, 05 Apr 2023 16:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20210112.gappssmtp.com; s=20210112; t=1680737980; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KaDXg7jQr8WqS+qCxmbGKAbggaVfUCyaQnmtEjxQ2HI=; b=y3q/4AdADXCzgGwG1DFSXiJCeJErECX2wfYCTQsFzQ2tnM1g+wen4QAwn0hL1KHq+R WoW3sUgE/pgxo2RyFH5+Bboe+Olu7MAr3oMxkRWo30wVROc6NlMTIIefMsJyb8SIa73p oZIFstUrca4Fwfj8m6kLcm7ZfdtQksE4Vp1lYt4VKULz5T0oOIFBpX19iTwLv5KCn5sI 8IyVECKFkNstpKx10XpH9rAxDgkAvPGrloxxkzu/pTrdkQEUUol3RhPVcaM47uyXd6bi AyLcMdV+8xKFPMybE9DV0oG9A7LuCWHTpNuMu6izAUxkQHXUnJ3o7jW5eEOIlmWETSaj NEhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680737980; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KaDXg7jQr8WqS+qCxmbGKAbggaVfUCyaQnmtEjxQ2HI=; b=dS7OqYv1JHxoW1yEdaSv/kCeVI0HEFV+Va0GK9Wg3GdG1s6/oDhgV+n8lu0C0M+hRH hU8zrn5rz5gt8Y0mPKG4rid1FE0zp8AFRSrl2kwhUpYWczNzLKoTcSWHwzcAGK+AU5+8 L359GU8yvA2zhuAMYFISR/6OIAH6mb01tXP5nK/hYzwNC3ukbBm9NlR1+v/O1cFU6PVt Z4cKlLzGw5KdTKkAX+bzTjKj6aLGmg/eChWs5MFVtDHkcNcuxLe8klS03WJ1lswPlgGd hhAGBaSO3/55Q2RjhjeMld7fqpx64ImAbj/8z5bG1CiVzcsot+Ypi2a5DVSV9ZD/Dtxl Pk3A== X-Gm-Message-State: AAQBX9c4zNnMY4lg08FK/HH0e913TU68Z+O7DKRt7Ije2CWq7GNXJfHw WtPnjMTX3Hza9V8JHRlKnZOv2fdsEJF8GIfbkMQTgbKT8Re2R3CbpiA= X-Google-Smtp-Source: AKy350bDmkhM2F+lfb2xc0xuUGZgl6LWDarMezvWp1g79PjaPDFmg5xeuqe2IJZ1r0PqRXQAned2T4kdk5QoXl7MLTI= X-Received: by 2002:a25:4b41:0:b0:b75:8ac3:d5d9 with SMTP id y62-20020a254b41000000b00b758ac3d5d9mr770283yba.3.1680737979777; Wed, 05 Apr 2023 16:39:39 -0700 (PDT) MIME-Version: 1.0 References: <642DF7C3.2020703@adviesenzo.nl> In-Reply-To: <642DF7C3.2020703@adviesenzo.nl> Date: Thu, 6 Apr 2023 01:39:29 +0200 Message-ID: To: Juliette Reinders Folmer Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Array spread append From: andreas@dqxtech.net (Andreas Hennings) > I have the feeling I'm missing something, but how would this compare to array join Array join does neither append nor replace if a numeric index already exist= s. But you can do [...$arr0, ...$arr1]. https://3v4l.org/CIinR print json_encode([ [...['a', 'b'], ...['c', 'd']], // [a, b, c, d] array_merge(['a', 'b'], ['c', 'd']), // [a, b, c, d] ['a', 'b'] + ['c', 'd'], // [a, b] array_replace(['a', 'b'], ['c', 'd']), // [c, d] ]); (I wish we could use yaml for these outputs) > $arr[...] =3D $arr2; Using spread in the array index would be different from current usage of the spread operator. But it could be a nice alternative to `$arr =3D [...$arr, $arr2]`, as it does not require to repeat the first variable. So I am not against it. --- Andreas On Thu, 6 Apr 2023 at 00:36, Juliette Reinders Folmer wrote: > > On 6-4-2023 0:12, Vorisek, Michael wrote: > > Hello, > > > > I would like to open a discussion for https://github.com/php/php-src/is= sues/10791 . > > [https://opengraph.githubassets.com/a23cb565cc8acac6a33ecab5d9ee68a46f0= 46a1ffe215501673156e506695430/php/php-src/issues/10791] > > Array spread append =C2=B7 Issue #10791 =C2=B7 php/php-src > > Description Currently spread operator can be used for almost anything. = But 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= and I belive it should be supported natively for shorter syntax, language = consistency and performance. > > > > I am unable to implement it, but I am ready to help with RFC. > > > > Michael Vorisek > > I have the feeling I'm missing something, but how would this compare to > array join (which is already available and is actually shorter than this)= ? > > $arr +=3D $arr2; > > Smile, > Juliette > >