Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114207 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6158 invoked from network); 27 Apr 2021 17:47:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Apr 2021 17:47:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6DC1518050A for ; Tue, 27 Apr 2021 10:51:45 -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-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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, 27 Apr 2021 10:51:44 -0700 (PDT) Received: by mail-oi1-f178.google.com with SMTP id n184so34480586oia.12 for ; Tue, 27 Apr 2021 10:51:44 -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=wxR7DEHIllwsnNTuK/38l5XoJc2HcflErpNxpby4LHQ=; b=URcEjrWO17k9T03wX2FzTDcJ7BMqYB5yUE2/2cxOiMwuE2DxWqolleKM2l4chHFt8p cz4XJ8bhGfevHg1D6CbXz00fRFR5Ojrs4S3V8ZNm0V0aO+Eh0JWR8KwQnjfsirXo0hy3 H0YVR2pEagU8f/CxD5wfxi0Q1asOgicl/zELKCzDUQWbbRdZloo7ERlyrWUoqj2759mX Vz+KCc5cI3L7sjjWhLLMIG+pMff0hv8klHgeiJHh2HazssFblwnb9w83ujWPhDrlFT6O Kbfg2h4dIB49VLwAzSNGFUYOrIziwFWEsaGc728tAjlDJRfnnu86vCkOrv9DYzIWDTlH vJPg== 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=wxR7DEHIllwsnNTuK/38l5XoJc2HcflErpNxpby4LHQ=; b=RId/xP6QrE30e3vryzAr3UTd3RqFynYFlwK1uACaUuCmTQH03rmhQcxkeBY2F+ta3v xzsf+xRmgnltn1sL2jOW95oDkL1p+UoztxXQZ7nq+YD3IvC2fp/NUx2OQIm4ljGs3K+a 4yo6v+deNcqZ+0C6/C8mBT5IwjvlDUQN7MT4FrdZM17cZYndemyytC/hgogWH3puovqu zWSufirRKaurSDpmqIhU/uhwC7zhdaG4he4F30TBNkiaJpBWXdfzzNcrQkAwkEybu1e2 f/DGCJ+5Tsk924GSrYfbRSIDEukHIdlVSK2Db/6GxIHJsWbQJpOlOkmcKKC5Z+YvOd9x IRFA== X-Gm-Message-State: AOAM5304s383S1v1lRFcWDkHV3/2FDlyCxE6N7MlD7BuTFsmwNdUkxVI Mf62VUGCO6b3ZEE0gN0TyEeZ746aNITWSrc2sqo= X-Google-Smtp-Source: ABdhPJx+wlW4T0nAiwugDyzcyluNVv33vOBBnFsQPrQ+HJoMOe3R3eXy3kUQgNEyBoHovlNhqABFOVz6xO1Wt17T3Ts= X-Received: by 2002:aca:c395:: with SMTP id t143mr4397816oif.152.1619545897225; Tue, 27 Apr 2021 10:51:37 -0700 (PDT) MIME-Version: 1.0 References: <5b9f1500-615a-48f1-815f-1d48b327ef90@processus.org> <179049b1475.11134368b213512.254739612773841999@void.tn> <722ed544-69e3-3be4-f828-185914617228@processus.org> In-Reply-To: <722ed544-69e3-3be4-f828-185914617228@processus.org> Date: Tue, 27 Apr 2021 18:51:25 +0100 Message-ID: To: Pierre Cc: Guilliam Xavier , Christian Schneider , PHP Internals Content-Type: multipart/alternative; boundary="000000000000e6d40105c0f7e990" Subject: Re: [PHP-DEV] [RFC][Draft] Sealed Classes From: davidgebler@gmail.com (David Gebler) --000000000000e6d40105c0f7e990 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 27, 2021 at 6:19 PM Pierre wrote: > Le 27/04/2021 =C3=A0 18:46, David Gebler a =C3=A9crit : > > What's being proposed in the RFC is a functional change to the language > > whereby attempting to extend a class designated as sealed to a > > non-specified child results in a fatal error. > > It's not a functional change to the language, well, it is a new feature, > but it's actually not changing any paradigm in the language or the > engine. People will continue to write the same code, and people that > want to use it for some library or customer project internal purpose may > use it. > If you introduce it, people will use it and the people who use their code will (no pun intended) inherit it. So the idea that no one is obligated to use this pattern if they don't want to is at least de facto untrue. > > > Now that is not a benefit in itself, it is merely a description of the > > proposed change. My question is who or what benefits from this change? > And > > I look at this way: > > > > 1. The language engine doesn't benefit, since unlike some compiled > > languages, there is no indication here it will result in improved opcod= e > > sequences. > > > > 2. The author of code doesn't benefit, to any extent greater than they > > would by using an attribute or other metadata to indicate their > intentions, > > because if someone else comes along, installs their library and creates > > problems for themselves by extending some concrete type in a manner whi= ch > > was not intended, the author's obligation to them is zero. If improperl= y > > inheriting or otherwise misusing code creates a problem for a consumer, > > it's the consumer's mess to sort out. > > I think that the debate "but if your seal your classes I won't be to > extend it" is overrated: it's not the language to chose whether or not > the library/software author can seal its classes or not, it's up the > library/software author to do its own choice. Agree, which is precisely why I challenge there is any need for it to be enforced in the language with a fatal error. > And in that regard, having > "sealed" classes in the language is actually bringing that possibility > to the library author, so it's more liberty. > > By design, by convention, in any of a company or an open source software > community, it can be legit to explicitly hard-seal stuff, for blocking > users when they are doing it wrong, if for example by attempting to > inherit they will break other existing piece code, for example. There's > many scenarios where it's legit to seal classes, and it can be a good > practice also (depend on your practices I guess). > > But if sealing means "you who want to change a behavior, you need to fix > other things deep in the code before being able to do that" then it's > good (and it's one of the use cases of sealing). > > So each time someone use the "but we won't be able to legitimately > extend your class" he's basically saying that people that do put very > thorough and strict conventions in their own code are wrong by nature > and don't understand what is good. It's almost an insult - please don't > misunderstand what I say, I entirely understand and appreciate your view here, but it's no more insulting than to say to your users "You are wrong by nature; I know your use-case better than you do (without even seeing it or having knowledge of it) and there is no legitimate reason for you to ever extend my class" > I don't think at any moment that any of the > people here really meant that, but it it's fundamentally what this > argument does: it says that some conventions are by nature bad and the > language should enforce people not to write code like this. I think the language should not enforce any practice, convention or code > style, it must remain neutral considering people's whereabouts, > workflows or practices. If one's want to seal his or her class, let him > or her do it. > Some conventions may or may not be bad by nature but that's not the argument I'm making, at all. The language enforcing one person's preferences over another's is exactly what you are advocating and I am cautioning against. > > I think this point/argument should be banned from this discussion. Given the behaviour we're talking about is literally the change proposed in the RFC, I find this a very strange take. > > Sealed classes are good under some conditions, maybe bad under others, > that's not the point, it's not about discussing each developer's, > community's or company's own conventions, but about is it OK technically > to add this feature to the language, and will it be or not a maintenance > burden, and finally will it actually break millions of lines of existing > code. > > I'm inclined to say yes, it is good to add this feature, and I'm > skeptical about the fact that it would break existing code (except for > people that named their classes "Permits"), there's many use cases I > wish I had it in the past. I can live with it, but sometime, it could be > the right tool. > > Regards, > > -- > > Pierre > > --000000000000e6d40105c0f7e990--