Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120563 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57863 invoked from network); 13 Jun 2023 15:51:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Jun 2023 15:51:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7B7A5180340 for ; Tue, 13 Jun 2023 08:51:33 -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.5 required=5.0 tests=BAYES_05,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: Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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, 13 Jun 2023 08:51:32 -0700 (PDT) Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6b162fa87d8so3065520a34.3 for ; Tue, 13 Jun 2023 08:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686671492; x=1689263492; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=X3uNpjugVlOO7pRq8UDsMHK0kqz7lWBDQ+J2WajuAOw=; b=UXBDCocqmmtPmxMs+8uR9uBhRH/WRYOExGR3aTdQch7t2ReHy4dvIUoBahL7JPScUl yf8FGDdcVbeH1IetlH4y+szJWL3EsHz03lcCV2S8o4gvfKJ7qJPDyO6ussIjzXgLKqqS Ue07nd4MCr6mdWFNyblYdgk7mcINh/jR3uHrlr1EzRCjpQy5UIZNLMXPCgkjccD2MvfP FB3M/RhBmEE2s5VoIblX/4kvC8jFf+1uDM0iOivy6q+tYsYmBbHmVONYS/02arU24hv1 3Tj8eIjN2/kcliW/WEP0e9W5eaiDoHAsz6SoaTkZKFSQeKppZ7ewMx0PNh7PoAZNSrgv Wh0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686671492; x=1689263492; 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=X3uNpjugVlOO7pRq8UDsMHK0kqz7lWBDQ+J2WajuAOw=; b=TQIb/fqWp5n5dG76x1AHbdMZB2USQAOISVbcwVJryC3GU5krlYCt/fEZcZbeOkjuqd 5qwN0/1ek9KKLWILGy+eI+F9EnG8fdUr+nUhrwIzmTMAMOzdp/3bAVQee5aGzrt8J2Tn 4817I9XTWhb00Yo/27LhTlX3gICpYF7P8mj7DyMR/yeXceXkOGRl6ec00dG0J97g6oJC 5QkJ0SEUccVH9NCL8hyQuHpGFjvH6BluGgXjMV79d6KnUrEKlutSyKWx+aXSyz/IxKIy vzGTwQ4b0a8ut6A76KIzCBtnV+KL+g5TBGV+7jtLbI9OQOoZIqAsQol8i5NDhcCJTmPE GoXA== X-Gm-Message-State: AC+VfDwbeJZshvegPS0JbPRsJwYVbtVgO3CWGvfF4NLFqRvw2lFRUqmS pIvDRXzgs/U8ftP3CzKyHT7xkPls3kTt/cZYgQ6A3EJT X-Google-Smtp-Source: ACHHUZ5JtbpEOaMUebmV6PxKzOIt0gLxOYhgW/3K0myeDw9V4hfq4hqnnFSZxOD+pS3eJ3q3AmdcnI/fQav4rauj+q0= X-Received: by 2002:a05:6870:5a8a:b0:1a6:afbd:af12 with SMTP id dt10-20020a0568705a8a00b001a6afbdaf12mr2297712oab.43.1686671492209; Tue, 13 Jun 2023 08:51:32 -0700 (PDT) MIME-Version: 1.0 References: <799ae864-6e25-4196-a5ce-0d74600a8378@app.fastmail.com> <280bcea8-9483-4191-80d3-81763a988290@app.fastmail.com> <5db38bc4-a6fd-4cb7-b10d-3ad1a590888c@app.fastmail.com> <39511e44-93cb-4fde-b0ec-ce24ee88f4be@app.fastmail.com> In-Reply-To: Date: Tue, 13 Jun 2023 17:51:20 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000255fdc05fe04cf38" Subject: Re: [PHP-DEV] [RFC] [Discussion] Clone with From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --000000000000255fdc05fe04cf38 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry, In this case, if the `with` happens first, then the new address object is > cloned needlessly, but that *probably* doesn't hurt anything. But $newAd= dr > !=3D=3D $p3->address. > Yes, I agree with this: "clone $this with ["x" =3D> "y"];" is the easiest t= o mentally model as a shorthand for "$self =3D clone $this; $self->x =3D "y";= ". If we agree with this model, then it would be weird to execute __clone() at the end indeed. But I think Nicolas' example explained this fact much better than I could. :) Also, separating __clone() from the rest of the clone opcode would be . And you are right, some objects may be cloned unnecessarily, which doesn't hurt, but isn't ideal for sure. I should mention that in ideal circumstances (when all properties are readonly + all of them are initialized during construction + none of them are mutable internally), deep cloning is not 100% required, unless only for defensive programming purposes. Regards, M=C3=A1t=C3=A9 --000000000000255fdc05fe04cf38--