Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115264 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90511 invoked from network); 1 Jul 2021 15:45:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jul 2021 15:45:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8DC3E1804D8 for ; Thu, 1 Jul 2021 09:05:57 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-Virus: No X-Envelope-From: Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 ; Thu, 1 Jul 2021 09:05:57 -0700 (PDT) Received: by mail-io1-f50.google.com with SMTP id i189so8145406ioa.8 for ; Thu, 01 Jul 2021 09:05:57 -0700 (PDT) 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=aItHUnEKddgUgSEO7lYotOP6dYqSKr6ffzDb37h3YZ4=; b=lv3nAmBcBEZGIQ5V2HDeNnDoFrVlIgt88jiBf7TRxsj5vhmeOuse0D7QSdE65RojD+ k8vm6rkej6UOx4Jm4S1Yfuwx86e8gaO1Ah6vGv+wfPl72JZIbO5kvGupOz2B3svhBe5j FxHEAPGCBX78Q+i/oW6v8+QtXU3ewemkincunaJoT90lY3QwKlyHAxcLfevFWhJudOm4 5tNZrV39623z8zdDs7FN1dWiJ+ll97ZsjNifyN8NpTZeF1ESlfwUnXIHFUhosVH9lPjh fRDETekkoSFJt1rOTynAa5XqFryh5ZNXJlaQ7QpfWXa6loBkHFYEt190C3mm5o9UXQUq Oi6w== 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=aItHUnEKddgUgSEO7lYotOP6dYqSKr6ffzDb37h3YZ4=; b=scn69hkNA4bFGFQC1M/gmG99kl4zS1bTfMHRkQFj37/zUfrjJl4Wq9OAn1fykXCXec 9Ik8fORJ1J7lQScDKtmiQX+XnccxaLbJC/+6f5ptF53F78A/0oVgvd+AFli/vi+edJfD PN3fvgPbLFBZfh/eEXo7DDEVYCSdxm+pZF8ncb1stcGs0ZBeySS93pf2brb31je9gv/R msTAuKkoAiBYm1PMcczG1bnzDIl486xPBBMMPyhuLKRUvXXJ6PD8KU/LOeW8IOwKyd4Y 5xNkizlPyvTidLmabaKRDxcDArRZvXXPK/yrxT7JesRlvTZcJ9LqDq9pjUBsw6zrbt55 dDyg== X-Gm-Message-State: AOAM531/7DU/z25r00oMBJh9RGxGoexdYLQLL21NAfrpKyk3gO7r562K n5EnNxqHqv+Ke6ZWsFNs/crmwRBeKAOuNi1A0tcPUmpq31k= X-Google-Smtp-Source: ABdhPJwee586gyU5gsQfkogAdqP0pRiYikQQ+vHyjt68aaYsUwrliebgP132HLQaQSoS3yf29mOrfrX09eFn2GTvxMQ= X-Received: by 2002:a02:cbdb:: with SMTP id u27mr540040jaq.3.1625155554159; Thu, 01 Jul 2021 09:05:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 1 Jul 2021 18:05:17 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000082b0be05c612031f" Subject: Re: [PHP-DEV] [VOTE] Readonly properties From: deleugyn@gmail.com (Deleu) --00000000000082b0be05c612031f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 1, 2021 at 5:25 PM Larry Garfield wrote: > On Thu, Jul 1, 2021, at 9:49 AM, Pierre wrote: > > Le 01/07/2021 =C3=A0 16:38, Nicolas Grekas a =C3=A9crit : > > > Hi NIkita, > > > > > > I voted against the proposal because it doesn't work with cloning at > all. > > > > > > Cloning is a critical feature of stateful objects, and we should solv= e > it > > > the same version that introduces readonly IMHO. > > > > > > If we figure out that we can't agree on a sensible improved behavior > for > > > cloning, we're going to be in a dead-end with readonly. > > > > > I respectfully disagree. > > > > Having readonly properties and immutable objects is a must have, but > > changing property of an object while cloning, not so much. There's many > > case where readonly properties will be valuable where you never need to > > clone your objects. Actually, cloning objects is not something you do > > every day. > > > > Please note that I agree with you that advanced / flexible clone > > semantics would be a nice to have, but I don't see the lack of it > > blocking for readonly properties. > > > > I personally don't have any real use case where I couldn't implement > > withers on my objects doing the same than dedicated advanced clone > > semantics. Could you please provide some real world examples ? People > > could change their minds if they could see why it's so blocking for you= . > > > > Regards, > > The most famous use case right now for with-er objects is PSR-7, which is > where the naming convention comes from. I cannot say how widely used it = is > outside of FIG-inspired value objects, but I am pretty sure it is used. > > The key point is that you rarely need to clone service objects; value > objects, however, you have to clone if you want to mutate. Look at any > PSR-7 pipleline. By design, it calls $request->withBlah($newBlah) a lot, > and returns a new object. That's the model that we want to support, and > make *easier* to do, but the readonly flag makes *harder* to do than the > status quo today. (See my previous post on the subject in the last threa= d.) > > There are use cases for readonly that don't require cloning. For those, > it's useful. I personally think asymmetric visibility would render > readonly unnecessary and redundant, but Nikita disagrees, and he's the on= e > writing the code so... :-) > > The best case scenario is by 8.2 we end up with asymmetric visibility and > clone-with, and combined with readonly we get a huge array of options for > how to lock down value objects and still make them evolvable. The worst > case scenario is we find that readonly cannot be extended to support > clone-with for some hand-wavy engine reasons, at which point it becomes > largely vestigial in favor of asymmetric visibility and clone-with. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > I'd say don't use readonly on PSR-7. I have so many use cases for readonly property and no use case for cloning. readonly syntax is far superior than asymmetric visibility and will be almost as good as Constructor Promotion Property. I would even go as far to say that I don't need anything more than just readonly as-is. I think the bigger picture here is how many use cases are there that would vastly benefit from this Vs how many use cases could potentially benefit from it but won't because of lack of cloning support. Of course everyone's opinion will be shaped by the universe they live in and in mine this RFC covers everything I need with no drawbacks and I honestly don't understand not wanting this just because of lack of cloning. --=20 Marco Aur=C3=A9lio Deleu --00000000000082b0be05c612031f--