Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120065 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31362 invoked from network); 18 Apr 2023 09:27:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Apr 2023 09:27:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B50F1804D5 for ; Tue, 18 Apr 2023 02:27:32 -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_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-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 ; Tue, 18 Apr 2023 02:27:31 -0700 (PDT) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-552fb3c2bb7so41057767b3.10 for ; Tue, 18 Apr 2023 02:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20221208.gappssmtp.com; s=20221208; t=1681810051; x=1684402051; 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=vjBJ4MELaw/iV0x0JTagn1tGFidPpGxZ8aZENVWpVms=; b=0YlEN5wusF5CGktetcFmAB0xa4ymc3rV8i6Uf+7RGJRhVIhaQ2iBSIy91c/pyZsyBb 24VBHAY8iXUL5aCPkmhF9R8rEihKoJIbQ5Owd5+sPzmNa+Ps6qaeAdlXhH7k6PpfhiWl V+Hz17WgtUOJInymZPL1MWHqhiJWFJpglndl9mi2CMcLdiuyauD+jrQtBekffJPgwmBD 3fXfsNQGAcaDTNJcnXTdrdlO4jGGroouMfXB/A0BT369bhsNHu3yz0xnE/+hLUz1xtp8 i8Ba08AKizjwnn9zi2vZJ7Y6aC0If8BIJrVhNgGwwr3XB0PkOKMMKQ5jMNCpsUt9gXN3 2qRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681810051; x=1684402051; 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=vjBJ4MELaw/iV0x0JTagn1tGFidPpGxZ8aZENVWpVms=; b=XiIDPQewhyl+x001GVnSv6hjO9L6E7VkZXTHw/IJo4MPY5ala+YDoKESp7LRPJvDhd aGxa9NEplE07unk+Rz5iB0PIcfmRbXFY81Xzrz7Q/3YYIdxxT2N0pwM1xmbUBn2Q/hjy xsvq7gN+dm40Uj796QiURq+R8xJd+WlN3e7CcfR97mUR1jO815uSmIabU3XD79EJWC3H W9aaxE6cj50+ZtbhIamjwNaWMILY4qrT66J2CRTEm4M1HdctDfRbO2BMvTP59U8X/flC EEhIE2bCGr59qo6OhnayRLT4D08PqsFWGAT46HEx79E7JLSUGkyA8/9dKitaplExoSRG cRzg== X-Gm-Message-State: AAQBX9cDjHIOdkFKzE3FcfqhpH28BmSzaB2WdrrtuMqEMzTKl3FqzCMn bjg6IsUIAs9zmvfYHGFzZTGHMy4r4osVNUDoz8UWTw== X-Google-Smtp-Source: AKy350bloDX1bekL49I46KnXsyd7cr17+tx2+hoGfO+Y2lTQ2VHYjlMg/rJ4/G+7nVXlFk0KVHtQTJC0Axx2zBTDW9w= X-Received: by 2002:a0d:d68e:0:b0:539:1b13:3d64 with SMTP id y136-20020a0dd68e000000b005391b133d64mr19223364ywd.48.1681810051270; Tue, 18 Apr 2023 02:27:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 18 Apr 2023 11:27:20 +0200 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] [Discussion] Clone with From: andreas@dqxtech.net (Andreas Hennings) Hello M=C3=A1t=C3=A9, internals, I have been waiting for this to happen :) Some feedback > However, in some cases it would be useful to reference property names as = expressions, e.g. when one needs to use =E2=80=9Cclone with=E2=80=9D in a f= oreach loop where the index is the property name and the loop variable is t= he value to be assigned. This is also possible using a slightly more verbos= e syntax: What about argument unpacking? I don't know if we can combine this with ":" syntax or only with "=3D>". clone $object with { ...$arr, ...['a' =3D> 'A', $b =3D> 'B'], ...(function () {yield 'x' =3D> 'X';})(), c: 'C', // or d =3D> 'D', // No mixing of ':' and '=3D>', we have to choose one. } If we want to go crazy in the future: (This would require another language feature of inline code blocks with return value or behaving as generator) clone $object with { ...{ yield 'a' =3D> 'A'; yield 'b' =3D> 'B'; }, ...{ return ['c' =3D> 'C'], } } -- Andreas On Mon, 17 Apr 2023 at 08:32, M=C3=A1t=C3=A9 Kocsis wrote: > > Hi Everyone, > > Quite some time after mentioning the "clone with" construct the first tim= e > (at the end of the > https://wiki.php.net/rfc/write_once_properties#run-time_behaviour section= ), > finally I managed to create a working implementation for this feature whi= ch > would make it possible to properly modify readonly properties > while simplifying how we write "wither" methods: > https://wiki.php.net/rfc/clone_with > > Regards, > M=C3=A1t=C3=A9 Kocsis