Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:120441
Return-Path: <kocsismate90@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 80726 invoked from network); 29 May 2023 23:22:50 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 29 May 2023 23:22:50 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id DB8D81804BC
	for <internals@lists.php.net>; Mon, 29 May 2023 16:22:48 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,
	RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,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: <kocsismate90@gmail.com>
Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41])
	(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 <internals@lists.php.net>; Mon, 29 May 2023 16:22:48 -0700 (PDT)
Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6af6db17a27so1374676a34.2
        for <internals@lists.php.net>; Mon, 29 May 2023 16:22:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20221208; t=1685402567; x=1687994567;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:from:to:cc:subject:date:message-id:reply-to;
        bh=qsY0Gq5IE1xvmRBG3lOEEVZ+vWdG20hSefQD+mdkTOU=;
        b=KBH0aGjtnl8N6x4KY9lOot89rkbzcGiEqU79hL0ZVSFMepcDs0c9Poc7PJHscfonPw
         mXiZiNmNcoXrKfqOe1sxmBU2sWyzN4dffuw9FO0PbjVNTG1VuvQl4yZ6r/V2XGTQYZ36
         oBClGpKUwj3n9QdAHNlBLkUobxqNIF6lsOGw5v/oZz9HywCNfh+SIdLBhudPKT+YVZYP
         MA43KmubvVIXDiNoTft/C0vO7zD8/dG98evhg7AiWWfzSU27FLSf14qf8KxJ29XsqWVj
         DCSWRL2+JTw9gLtfkgmLUOimWnMfV9C6gNWArWWTfULzJsHT16x5bL8+JA9133kSELVk
         V6Lg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20221208; t=1685402567; x=1687994567;
        h=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=qsY0Gq5IE1xvmRBG3lOEEVZ+vWdG20hSefQD+mdkTOU=;
        b=d6SRMiLCOd2PWFuFbMmekDC3gIPwUOhBfkes0ks4ZFpGYW5Z/OY3K/6+yAzSdPArHw
         gWRNpYXtASp07Pd6B4YdjFWDARnw4xwfWQ97ZUInBxrtz5dpwSMjU6jPNjB49XhlAsrv
         X1p+dm4BP6UgUEhBqjSwxAkUwNFdrCdJvdHVs++ouaTSiVXBaz8jZ8EpoN1rjdR71Txz
         e0RcwYoHHxRkfuakC2uvI8BZRlyyhALrYNL+VUBWy6toDTinJJxGcepbMnqKohx2Jejt
         uwGKfJ2wBIuUWzAj/n2XS0c/GwnYy3LHIC502+hHYf2kP0ieIiw3S4XBrNJpK1X6/T3S
         0CRQ==
X-Gm-Message-State: AC+VfDyEBvngZgQ+6TLEEEfoKKFeJzsBiTXyWj+57oejUgGmv3Ez9Gzj
	IDCfOtRccVOKBQmIoxXlH5eED2cRryJxQF7V94F45TI2XjHB1G1W
X-Google-Smtp-Source: ACHHUZ6OUHqx8urCwc9wTCmaI1Mm/xO+bYXnuuAqXypo3rFaxt8NPuHBxZnQWV+em6jtuJwDroUk2/HCoW5+OnhbRI0=
X-Received: by 2002:a05:6870:90c5:b0:18d:4738:33fc with SMTP id
 s5-20020a05687090c500b0018d473833fcmr140331oab.37.1685402567394; Mon, 29 May
 2023 16:22:47 -0700 (PDT)
MIME-Version: 1.0
References: <CAH5C8xUn2wotLg0L7KZHoOGf3q-UqbL=47p2PLzK_mOBb=MJXQ@mail.gmail.com>
 <CAOWwgpncdhKvhwiAFUh_c_8+_vr=u9HhYxws_WZArh7W3Fi0xw@mail.gmail.com>
 <799ae864-6e25-4196-a5ce-0d74600a8378@app.fastmail.com> <CAAwdEzCbRdDHN=WYZy_jnyrM9USG9k9bxn=AW-KVWB8iSrBmrQ@mail.gmail.com>
 <CAOWwgp=Ch2iwOzxooiRcfk3WYMz-eYmQ51M-UP2Hh3bDogX5uw@mail.gmail.com>
 <CAH5C8xV76ou5Edpvq-vzb6RytW5-3uGanX+Sqf92-qnH26ccBw@mail.gmail.com>
 <CABdc3WqsVq4Jo1tt5EOevQ15aXhLA1+6SRmSENc8-K7SHX20Hg@mail.gmail.com> <280bcea8-9483-4191-80d3-81763a988290@app.fastmail.com>
In-Reply-To: <280bcea8-9483-4191-80d3-81763a988290@app.fastmail.com>
Date: Tue, 30 May 2023 01:22:36 +0200
Message-ID: <CAH5C8xVhiByYaRqF8nKqj=m=xanPt=WDOPOy0Rt3G48pNutJ6Q@mail.gmail.com>
To: Larry Garfield <larry@garfieldtech.com>
Cc: php internals <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="000000000000554d9205fcdd5d13"
Subject: Re: [PHP-DEV] [RFC] [Discussion] Clone with
From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=)

--000000000000554d9205fcdd5d13
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Micha=C5=82 and Larry,

As Tim has already clarified, using literal strings in the left-hand side
of "clone with expressions" won't cause any issues
for IDEs and static analysers to identify the correct property. I got rid
of the shorthand syntax from the proposal because
it is not strictly required (since it has an equivalent alternative), and I
acknowledge the fact that there are certain people
who don't want to have two syntaxes to express the same thing. If it turns
out that we really want to have the short-hand
syntax as well, we can always add support for it later.

Conversely, using the named arguments style syntax (what future scope calls
> a shorthand, which I don't think is accurate as it's nearly the same amou=
nt
> of typing)


I'm just using the same wording as Nikita used in his named argument RFC.
Please take a look at the following section:
https://wiki.php.net/rfc/named_params#shorthand_syntax_for_matching_paramet=
er_and_variable_name
Especially this sentence is important:

If I wanted to put these ideas into a general framework, I think one way to
> go about this would be as follows:
> - Consider identifier: $expr as a shorthand for "identifier" =3D> $expr.


Even though the shorthand syntax is only 4 characters shorter than the
normal one (including the missing space before the colon),
for a typical property name which may be 4-8 characters long (I guess),
it's a significant reduction of typing.

That approach, taken now, gives us all the flexibility people have been
> asking for, reuses the existing named arguments syntax entirely, and is t=
he
> most refactorable option.
>

Your suggestion is very interesting/promising... However, I'm a bit worried
that if I only supported the "identifier: expression" syntax for
"clone assignments", and I required people to pass an array (or splatted
array) instead of the "expression =3D> expression" syntax,
they would start complaining why they cannot directly use expressions as
property names... That's why I think all the alternatives are useful
on their own, but only the "expressions =3D> expression" syntax is
vital, since all the other use-cases can be written like this.


> Additionally, the current "property names expression" section shows a ver=
y
> odd example.  It's recloning the object N times, reinvoking the __clone
> method each time, and reassigning a single property.  If you're updating
> several properties at once, that is extremely inefficient.  Dynamic
> property names are not the solution there; allowing the list to be dynami=
c
> in the first place is, and that should not be punted to future scope.
>

I'm aware that it's currently inefficient, but it's the case only when you
want to update a dynamic list of properties. In my opinion, you update
a fixed set of properties most of the time
(e.g. Psr\Http\Message\ResponseInterface::withStatus()), and it's only a
rare case when you need
more dynamic behavior. That's why I believe it's not a huge problem to keep
cloning objects unnecessarily until we add support for the stuff
mentioned in the future scope section.

I am also confused by the choice to make __clone() run before with with
> properties.  I would have expected it to be the other way around.  Can yo=
u
> explain (in the RFC) why you did it that way?  That seems more limiting
> than the alternative, as you cannot forward-pass information to __clone()
> this way.
>

To be honest, the current behavior seemed like the natural choice for
me, and I didn't really consider to execute the __clone() method after the
clone assignments.
Do you have a use-case in mind when you need to forward-pass information to
__clone()?

Regards,
M=C3=A1t=C3=A9

--000000000000554d9205fcdd5d13--