Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118425 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12629 invoked from network); 12 Aug 2022 00:50:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Aug 2022 00:50:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 19DAA1804B5 for ; Thu, 11 Aug 2022 19:52:11 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,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-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 ; Thu, 11 Aug 2022 19:52:10 -0700 (PDT) Received: by mail-qv1-f48.google.com with SMTP id h8so14725062qvs.6 for ; Thu, 11 Aug 2022 19:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20210112.gappssmtp.com; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc; bh=cxkE+6t2avYJ5DaGH/Tr5Z9B0ifconRwuyoXbrlTQUM=; b=HjoBskD+IgZx1kxzc3E1nhDBWKrfyEYqODg/DN9Bv11fsxisi9++TtljDuJ1z+vdpd v4RAcUE9FTttS4O66RH0I4Fd4WgFxeYiTZCewflw4cGkxtTFQ+2vnkhiKI+dKGuIxuf8 pRxRlpb06GI0GTQY+ZlsYyFqEUpu9kNzehYdy2ArUDwHhJE7JXLML3M1KZlf/nH6Yjdg 2Ew76luEUYX+2dgY2mNIKeQeV8sJF5riTR3Uu7Z+dwIU1cx9DJBq5OnZ4sY/GDzudga9 pa0BSny2BCCE/rutAxIqkGp2ORJUy5KTIy8mar1nRxETPFOYrI3dHSskeS73TzZYgLji x9kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc; bh=cxkE+6t2avYJ5DaGH/Tr5Z9B0ifconRwuyoXbrlTQUM=; b=u/1q3u9rWFg6r6s7qw6uV5CvsGw13lFsFLgWAkCX32GKocmLEk01n0CGzhqjGlwzkt 7S3g56g1FmAVjfU8dMSj4MAnEfW1q0BievrQA/C4EctOudeq/VJd1CYkjF89XyugXasA x2GMj+kw9u3Tm8BlF9uQt4dIPXuOkuDwKfWGULgLmnNcSAzYLBGLVxnhZpPjCGsv68hC Mt0J04quvevUvBI7hwlIp9Ku8fIxAexWtPZgH8R1hhgfbQGCuVq9SeAOSGHtDVddNFpx oVKPGzcc5ggoDbLMrPMg7K4I7wOEhKI+Ur9KM9jyQ+5+sVtoWRBKUbeW48qt7LcD4zsn /hlA== X-Gm-Message-State: ACgBeo21DFp74JisI0i9JjNmcYCRL/ZpUDs/oxVBbjrUeKfyb9crWPwr 8sEScDHIEfZjRuTwd+3NtxVepQ== X-Google-Smtp-Source: AA6agR6l2CaL7go4rn1SpcRfNvpn5zSNMOfyt5ChuXXKc68K9nndjru+TE06N7oxziovB2aI98vbhw== X-Received: by 2002:ad4:5c8b:0:b0:474:97fb:c4e6 with SMTP id o11-20020ad45c8b000000b0047497fbc4e6mr1749717qvh.68.1660272729787; Thu, 11 Aug 2022 19:52:09 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id do4-20020a05620a2b0400b006b640efe6dasm734565qkb.132.2022.08.11.19.52.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Aug 2022 19:52:09 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_BD25F6ED-ED37-4EEE-905B-91AFF97F3B7F" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Thu, 11 Aug 2022 22:52:08 -0400 In-Reply-To: <0e6401d8addb$651ca9d0$2f55fd70$@webkr.de> Cc: php internals To: =?utf-8?B?QW5kcsOpIEjDpG5zZWw=?= References: <0e6401d8addb$651ca9d0$2f55fd70$@webkr.de> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_BD25F6ED-ED37-4EEE-905B-91AFF97F3B7F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 11, 2022, at 7:38 PM, Andr=C3=A9 H=C3=A4nsel = wrote: >=20 > Nicolas Grekas wrote: >=20 >> But I'm also wondering about the use case where asymmetry would be >> useful in practice now that we have readonly? >> I voted against readonly at the time because it didn't address >> cloning, and also because it deprives end-users vs code authors IMHO >> (alike "final"). I would have very much prefered asymmetric >> visibility back then. But now that we are here, what are the use = cases? >=20 > Isn't it (obviously?) to have setters that ensure all invariants of = the > properties are met? I'd still rather have Property Accessors as > described in https://wiki.php.net/rfc/property_accessors, but I think > AV is a step in the right direction. >=20 > As for readonly, I don't understand why that exists at all. For immutability.=20 Here is one reference on immutability offered up by the google gods: = https://hackernoon.com/5-benefits-of-immutable-objects-worth-considering-f= or-your-next-project-f98e7e85b6ac = Immutability goes hand-in-hand with Functional Programming (FP.) While = PHP is not a functional programming language, PHP developers can gain = benefits from an FP style for which immutability is beneficial.=20 Also from the google gods, if you are unfamiliar with FP: = https://alvinalexander.com/scala/fp-book/benefits-of-functional-programmin= g/ = =20 Hope this helps. -Mike P.S. Also, the Internals list's very own Larry Garfield is a huge = advocate for FP in PHP, voil=C3=A0: https://leanpub.com/thinking-functionally-in-php https://www.garfieldtech.com/taxonomy/term/95 > Yes, it's > good that readonly properties can only be set from within the class, > but only once, so you get setters that throw when called a second = time, > which I think is very, VERY unexpected behavior. Calling them > "readonly" is also somewhat misleading because of course the objects > assigned to those "readonly" properties can still be mutated, they can > just not be reassigned. >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 --Apple-Mail=_BD25F6ED-ED37-4EEE-905B-91AFF97F3B7F--