Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114141 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49788 invoked from network); 24 Apr 2021 23:36:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Apr 2021 23:36:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4EFDC1804CC for ; Sat, 24 Apr 2021 16:40:02 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 ; Sat, 24 Apr 2021 16:40:01 -0700 (PDT) Received: by mail-oo1-f46.google.com with SMTP id m25-20020a4abc990000b02901ed4500e31dso4473564oop.1 for ; Sat, 24 Apr 2021 16:40:01 -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; bh=5z6YmsdxI/C3VkRS9ykjNeLDkArweODAZbIVWxCWqbI=; b=LRRQi1tG9A1P3J5EZNZ0NiCt9/JoVHobNXept8unW7J56CBe/oIHw7OMD0rN1QF63U dN3smFFOD/H3T/BsTulnvuDfB9oKsuRs0TLD9R4z8LzL2rAAfXBYHJ2QTFn9oG4f47DR AMIwtzlHF6NViouodXimvBIBQvEmmyTjiNFkITgR5MZkzDKs/LtBybyXkMJNH1xxzFVh AAyDc/qPCZuA56QKNZgT53o/yesZaaK+CKsEkcYbzdVZvVAuQ7sn3+IEFD/xpHFipvKe U6rzQUSdzRFQp1gnwJ4HYey/+6HDcDZIabW1uHNssLvreA7BEZISL4QRow7eB+ApsSTc 0/cQ== 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; bh=5z6YmsdxI/C3VkRS9ykjNeLDkArweODAZbIVWxCWqbI=; b=BRMlBold3gxzDybF6Ff/MWJFOrzKMTN+rvPZzzndam1qVYi6FjUsjd6+JC8lPTzA97 wmLd/AOrWqbBODFEmYcsbEBF59rUl8P0eQ31I91UWzbR4FAxchH/bs8w3AW7Z/c9BXvD e+bk3mkeQCTH/BO9R9r6nGwW1juaJOaMS0DVyy9vGmxB5H+uo+JvFduc4pi2s+s3nt+w HjCwDHtdIr/3MszeZ0eutfSnfpR9xtANIBG6HxV1RASqvs4Fk+wGdy3JZZ6fdo0G39Vc ouSknP3md1i0SGRjQxtMQkNjWsYopxeqnqYOGce2Lz053T5QbLS2Ujopu3z4rV71S6xN xfmw== X-Gm-Message-State: AOAM533prG+tzvGYP7w5spmLlI7JV0WZ9nGTaEDtl5dZKk3FTdPSGBQ+ IsCcrgRzCsIdTBrB3tbBYaXsZHFMB7aaTsCMxdep3Md/yZzTQQ== X-Google-Smtp-Source: ABdhPJztj1vGWi4/Da0lro5g8muILQ0x+LNLEgAQP4jh7uDNSqYS6oDHuuGYW1m5nlwksvPMK9dG1nIYrR0wD7Bbdx8= X-Received: by 2002:a4a:960c:: with SMTP id q12mr7879442ooi.83.1619307597071; Sat, 24 Apr 2021 16:39:57 -0700 (PDT) MIME-Version: 1.0 References: <5b9f1500-615a-48f1-815f-1d48b327ef90@processus.org> <179049b1475.11134368b213512.254739612773841999@void.tn> In-Reply-To: Date: Sun, 25 Apr 2021 00:39:47 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000001b079d05c0c06eac" Subject: Re: [PHP-DEV] [RFC][Draft] Sealed Classes From: davidgebler@gmail.com (David Gebler) --0000000000001b079d05c0c06eac Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't love this idea, I'm not very fond of the final keyword, either; I've always believed annotations (or attributes in PHP these days) are a better of way of indicating you, as an author of a class, did not write it with inheritability in mind or intended than restricting language features through syntactic constructs. The RFC says "when you have a class in your code base that shares some implementation detail between 2 or more other objects, your only protection against others making use of this class is to add `@internal` annotation, which doesn't offer any runtime guarantee that no one is extending this object", to which I ask - why do you need this guarantee? What does it qualitatively add? If I make a judgement that I want to extend your class or implement your interface, I can just delete the sealed keyword from your code and carry on. So it doesn't actually offer any guarantee at all that I'm not extending the type. The best it can achieve is to indicate your intentions, which I believe can be adequately done today through an attribute, no addition to the language needed. On Sat, Apr 24, 2021 at 9:01 PM Christian Schneider wrote: > Am 24.04.2021 um 21:51 schrieb Marco Pivetta : > > On Sat, Apr 24, 2021, 21:44 Olle H=C3=A4rstedt > wrote: > > > >> 2021-04-24 17:59 GMT+02:00, Saif Eddin Gmati : > >>>> Doesn't this violate the principle: It should be possible to add new > >>>> features without touching old code? > >>> > >>> This depends on which syntax is picked, both `for` and attribute synt= ax > >> will > >>> be completely BC. > >> > >> I'm not talking about BC, but the maintainability of the new feature > >> itself. For the shape example, you'd need to edit the original file > >> for each new shape you add, which is detrimental for maintainability > >> and scalability. So what's a good use-case? > > I'm with Olle here: This sounds like an anti-pattern to me. > The example could not be worse: Why should I not be allowed to add a > hexagon shape? > > > The main use-case of sealed types is being able to declare total > functions > > around them. > > Could you elaborate on what's the real-world use-case for your main > use-case? > This sounds like another case of a feature based in (math) theory which > leads to artificially locked down code. > > - Chris > > --0000000000001b079d05c0c06eac--