Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114173 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71963 invoked from network); 25 Apr 2021 22:32:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2021 22:32:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2ADA31804B5 for ; Sun, 25 Apr 2021 15:36:12 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 25 Apr 2021 15:36:11 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 58ED95C00B6 for ; Sun, 25 Apr 2021 18:36:11 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Sun, 25 Apr 2021 18:36:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=32/y9a NnKLsIvo4eeQrByHL49EYAOcsnWSL9Np0/LKs=; b=Nuv9rpkOWFH1UvgeYQmOLv hrbtYPNiqHn1oWvu9s33V0jCZH5CxqlGNvRkGrdlwAyhDqNIl9Z+qps1I92ZLXYF rs0b97B+KecZSDW+LiHegSWZ26WQMXA6jTcQxjcFtiYOCpXWcZDyW2KCysKahnh+ fluq1rG2yn01Itz5YiNXfBa/ih5UjBVs11umCgrV5GhzlFOSRAkfKKm4eJVOSwao D6c2BpbwHvar5PtXcc5TbZVZ03gxbR1IKO0cURwknIHiwwkp/cj9zumoAV1oHbmI ov2McPMhvrcmoAX0z7A+SjnhcC8t4rcpTfI6pjt/xiIYCqGsDvxy53+zwqEq8RAg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddujedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id F088B3A02D2; Sun, 25 Apr 2021 18:36:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-403-gbc3c488b23-fm-20210419.005-gbc3c488b Mime-Version: 1.0 Message-ID: <90753dbf-37a8-4f58-8158-e27f65b932fd@www.fastmail.com> In-Reply-To: References: <5b9f1500-615a-48f1-815f-1d48b327ef90@processus.org> <179049b1475.11134368b213512.254739612773841999@void.tn> <0BF84585-DDC3-4B25-BFD2-D8B916D135EE@newclarity.net> Date: Sun, 25 Apr 2021 17:35:48 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC][Draft] Sealed Classes From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 25, 2021, at 3:51 PM, David Gebler wrote: > My argument is not that there aren't legitimate cases where you want to > indicate a class or interface as sealed, nor that developers should not be > empowered to make this indication. Right here is the core point. This is a subjective statement, and one with which I (and apparently many here) disagree. Note that the *exact* same argument could be made for typing parameters. I can document via a docblock that I expect a given parameter to be a string, or a Request object, or whatever. "There is little to no benefit in expressing that through a new language construct rather than through existing constructs and design patterns." Except there very much is a benefit, for making the intent of code clearer and for allowing the engine to syntactically make certain invalid states impossible. Adding more typing power to PHP has been a phenomenal win over the past 15 years precisely because it converts certain bugs and error conditions into fatal errors with no additional work required on the part of the developer. That is a *good thing*. ADTs, sealed classes, enum, and other functionality in that space is a continuation of the same process: Allow developers to use the language syntax to make invalid states impossible to describe, and thus bugs from invalid state go away. Documentation, in whatever form, simply can't do that. It has nothing to do with "inheritance is dangerous." It has to do with accurately and completely describing the problem space. Also, sure, you can fork any library and hack out the parts you don't like. That is true for sealed classes, for enums, for property types, for the entire language. It's also completely 100% irrelevant, precisely because you're modifying upstream code, so all bets are off anyway. --Larry Garfield