Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108751 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33137 invoked from network); 25 Feb 2020 10:47:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Feb 2020 10:47:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 669691801FD for ; Tue, 25 Feb 2020 01:04:46 -0800 (PST) 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.8 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_H2, SPF_HELO_NONE,SPF_PASS 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-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Feb 2020 01:04:45 -0800 (PST) Received: by mail-vs1-f42.google.com with SMTP id t12so7524005vso.13 for ; Tue, 25 Feb 2020 01:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DnENlmKEfT/saWcYhkfI4c4uNlVa2IyAjfsdP0Klrxs=; b=tInap+TR1nc+JudqbbB1TfB6dMe0+OMaz8LelVrsFryu7H3FOXaVNTyI+VELNv4uB+ dI5RXQx0RdSNyCL79JN7GoMp96zq15arskBuU5o/K5U98YHmlb2KOlnfPT8yAfgA5rFc d575K+k+f9Vu0fBAr/vnvQyyiwFtjaIZTXaYs2AwVfnRzT7drqdGhvH8e8lgsy1EI01t YGF/eNTWByul4LESxAzJo2vAi4AD5yrgikYHJQW/J9FNmx2vI1qNlwDU5Vovarr3ar2U 1OANizQsaFOCCSYyq8EQJIXBHmPMkw4UDbiNIS3jVWwG6odr8VGsq5OqjRZiaYLebJP2 IggA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DnENlmKEfT/saWcYhkfI4c4uNlVa2IyAjfsdP0Klrxs=; b=Z3soEiy9Ne1QLAGoV3rYjjMrFOyHQK+o/1vA3yZ/nensF6seiAM5Ek12XL4X2gcaQI 0A84owejKZuFkNpTsGjqlVa91+11/nbEz2FI7o1VYYxPEQAah3Q/svL3M9yT7/trYN1g RqnC2/hOH6QXBZBHAHfTLeLcmMMm+xASQ2u1kMYbNuAqPeh/Z7ubzW4Xs+2zeNLv70f4 b1HiCNbpJleJQA983HwAn1FpJ6kcE6vKCiNgv3EO+Y9GQVp0D1YjbiWk2pafp6ko1D9h e67P+f2XhktnIgB1paMZDnfqAWSXBWKG3R4rgYAI2uCcer1KzYWYa6iwW9Nd6l9NS23h 09Xg== X-Gm-Message-State: APjAAAVhC0gJ3FF9/2L+EyaEdQjLWKWxaOCHMc1+y3q5eydl12QujFZk /FnhoBuQhBDScDsXol41nEOszhHCIbIutkkUxE+NXncP X-Google-Smtp-Source: APXvYqz3ClDAT/XzLTZnKnOiabABZwguAmQ7KwUSR1AUfM0OIyLKFs7x06rBHCPwtSJEfABuT3u5Y+J/AhkC8H4hpOI= X-Received: by 2002:a67:fa51:: with SMTP id j17mr30270111vsq.59.1582621481418; Tue, 25 Feb 2020 01:04:41 -0800 (PST) MIME-Version: 1.0 References: <8545d15e-ddd5-42be-8405-09697a077234@www.fastmail.com> <4d9688fe-cc57-44af-903e-05f4cbb1bbcc@www.fastmail.com> <452D962A-C588-4F04-B000-479EBEA9B9DB@newclarity.net> <9ebc648c-39d1-45b1-9f3d-9a799c6dec93@www.fastmail.com> <01FE7634-51EC-4D94-B4A0-62C477C096EA@newclarity.net> <726da829-6124-4331-8b28-4d654d652b2a@www.fastmail.com> In-Reply-To: <726da829-6124-4331-8b28-4d654d652b2a@www.fastmail.com> Date: Tue, 25 Feb 2020 10:04:30 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000036c3c9059f62c79b" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Immutable/final/readonly properties From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --00000000000036c3c9059f62c79b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable My original idea was to discuss cloning in connection with immutable objects, - I think it's only a serious problem in that case - but we can bring this discussion earlier of course, as readonly properties certainly has some effect on the clonability of objects. When I started working on implementing immutable objects, I tried to come up with a solution for the problem of property mutation. Actually, I even had a short discussion with Nikita about the topic. He proposed the following syntax (which is inspired by Rust): public function withFoo(FooT $foo): static { return new static { foo =3D> $foo, ...$this }; } My idea was very similar, but it affects cloning: $self =3D clone $this with { foo =3D> $foo, ... } I also tried to experiment with similar solutions to the ones proposed by Rowan, where readonly properties were unsealed after cloning (in certain circumstances), but my general feeling was these are not the way to go. To be honest, I also don't really like object initializers because they omit invoking the constructor. However, "beefing up" cloning would make sense for me. Given, adding support for object initializers (or a special for of it), is also a non-trivial problem - as seen in case of the previous RFC -, and given, the absence of this construct is not a deal-breaker for readonly properties, I still think that it would be worth to separate the two topic (and vote separately). This way, we can keep the current proposal self-contained and focused. If the current vote passed, I'd certainly try to address the problem of property mutation after cloning in the immutable object proposal. Regards, M=C3=A1t=C3=A9 --00000000000036c3c9059f62c79b--