Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117354 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53087 invoked from network); 17 Mar 2022 12:11:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2022 12:11:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B843118050B for ; Thu, 17 Mar 2022 06:36:54 -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,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS62371 185.70.40.0/24 X-Spam-Virus: No X-Envelope-From: Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) (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, 17 Mar 2022 06:36:54 -0700 (PDT) Date: Thu, 17 Mar 2022 13:36:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1647524211; bh=swZ3WV70wlG3CnLp/H24U04u1SgzJ4swerr+x2ShLGY=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=OCjX0ifdYSH4C2leFu1f5UXmlQr9PLNoq44uGBz2DO5yeKbZfuKKhOCUuAAZdxPwQ lDj8drcrBC9DLWRyX0BsLbTvOOtv2r2CeY6Kwuq/5X4UDlK5pv3j2X2qhqHzTLEgfG JJPqOrCA6qVmtJygMnxaiQajfzujjum6qhTXcKwr0dIlU/Ysg9+GA6VPQDkpdu2Hg7 8jA3xkA5L7eA7LkltfyH/515bECYMR71V3hl4fm6Bp/LNilxeNkwQd1KcFti02EU6M laFdXtBESpWXum/tE4S+sD3kMaJOzIhmzEShI37mKuQDgJSohbPzRupi4nI7BfPR0O vH7XaRcuWZI3w== To: Nicolas Grekas Cc: PHP Internals Reply-To: Saif Eddin Gmati Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="------8ab1dddf25d15838047004d6d354d25a4a343c422d602b78d1d5fc4fe0cf547f"; charset=utf-8 Subject: Re: [PHP-DEV] [RFC] [VOTE] Sealed Classes From: azjezz@protonmail.com (Saif Eddin Gmati) --------8ab1dddf25d15838047004d6d354d25a4a343c422d602b78d1d5fc4fe0cf547f Content-Type: multipart/mixed;boundary=---------------------55a3ed3977b5b1b54df6614ab5ac89fe -----------------------55a3ed3977b5b1b54df6614ab5ac89fe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain;charset=utf-8 On Thursday, March 17th, 2022 at 11:38 AM, Nicolas Grekas wrote: > Le jeu. 17 mars 2022 =C3=A0 04:54, Saif Eddin Gmati azjezz@protonmail.co= m a > = > =C3=A9crit : > = > > Hello Internals, > > = > > As per my last email in the previous thread, i have started the vote f= or > > = > > sealed classes feature. > > = > > The vote will run for 2 weeks until March 31st 2022. > > = > > Discussion: https://externals.io/message/117173 > > = > > Draft Discussion: https://externals.io/message/114116 > > = > > RFC: https://wiki.php.net/rfc/sealed_classes > = > Hello Saif, > = > Thanks for the RFC. > = > I voted "no" because to me this closes extensibility in a hard way. If > = > users are fine ignoring an "@internal" annotation, or using reflection t= o > = > access private symbols, then I think that's fine: their problem; they kn= ow > = > why they need to do so - not authors. Allowing authors to forcibly remov= e > = > that capability from users is going too deep into removing power from us= ers. > = > Said another way, I don't think this solves any problem that authors fac= e > = > in practice. As such I don't think this is worth the added language > = > complexity + removal of power. > = > Cheers, > = > Nicolas Hello Nicolas, > to me this closes extensibility in a hard way. This is not necessarily true, we have `final` in PHP which does exactly th= at, but `sealed` can still allow for extensibility, just from a different = point, e.g: ``` sealed interface Option permits Some, None { } interface Some extends Option {} interface None extends Option {} ``` In this example, both `Some` and `None` are open for extension, but `Optio= n` is closed for any type aside from `Some` and `None`. > I don't think this solves any problem that authors face in practice It does! Considering the `Option`/`Some`/`None` example above, given `Option`, now = you are sure that it's either an instance of `Some` or `None`, where previ= ously, a third type could exist. Authors previously got around this issue by adding methods on `Option` suc= h as `isSome()`/`isNone()`/`isSuccess()`/`isFailure()` .. etc reference: https://github.com/azjezz/psl/tree/2.0.x/src/Psl/Result Having sealed classes, ensures that there can't be a third type at runtime= , and makes the `is*()` methods absolute, as now you can check the instanc= e type. Regards, Saif. -----------------------55a3ed3977b5b1b54df6614ab5ac89fe-- --------8ab1dddf25d15838047004d6d354d25a4a343c422d602b78d1d5fc4fe0cf547f Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wsFzBAEBCAAGBQJiMzlWACEJELAOCkaz8cFXFiEEOazMpP0wDQTIQG6zsA4K RrPxwVejlg//Z2DBkYsBW8UUMCrSLjNdh9izfsLgzTRW5bIBuB3huoJnOqCj C99+xuK62zlCROI+LZrf+GEDnhCvMtmzKGBaHiINJO8hw8w/hK86DnUgqEqz YYdIVBbC3r1yMC6ccdj/luT2Ma0A78E84m0x7OsbrX3idCJwZDxUIbquf88c EEi/FK2YPVADr7MlstTzxHvMb+CpcNKqtJKliZ04hCuQBfBQn4tdoQuIu2OW CKCKGZh1RTz28+ov3MjnXycJ+DhlHIRkxSL+g9+xAOPpOOcrCZBEOgk6c1SA V0QDvl/Jk1WSQB2MiJPVFAf+bNhFzsRTXk682JgKGMztx/QXOWDdbvYwTeoP DNJtJHXhRaxgAyQbwegWFFEo/zRjpP8JAAehPwE5PxVjMBCA9ZdZXeps1Zui tBUTXGr5VFpoBwyT4NQStWMvrrP1Ra7uBTP/idR9b+34UX2HwZ0YMFDPFQwG 82bjSRnGbM8DGQ2wzpi8/eoae/yNTRv/miFAIQB7q5OR35z1ku3mMmC8xmLb OAouNSQuHsiTgTAeKKoOVXeSt/m8xoPRnCfmHVkdhOSBehA5QXGjl2ohcnlb e3bzcIYx6weR/LlqKA+uyhtiyRzmz77FIwKasktA4sPIpKoDY1F71JXI2R1v pxM1LwBnho7Fhi2Z9SHyS9CbrutCXmblxo4= =tZHJ -----END PGP SIGNATURE----- --------8ab1dddf25d15838047004d6d354d25a4a343c422d602b78d1d5fc4fe0cf547f--