Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117356 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58747 invoked from network); 17 Mar 2022 13:29:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2022 13:29:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 882CA180382 for ; Thu, 17 Mar 2022 07:54:47 -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=-0.7 required=5.0 tests=BAYES_05,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, 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-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 07:54:47 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id h1so6867422edj.1 for ; Thu, 17 Mar 2022 07:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pW5sFrDbeVX26WrkS+PKzcHvaR9BQXLwgH6hOfMBAs8=; b=fQ34niJPRIqfolAc4JkuzwgmG72TLQlhFgtF5hwa/keHPet2XXkUFy5iauy7j+77Mf c4+3VwJ4AYcZIDJWoCA4nev3K/gmof5GupQ9pBuat+IeINxMeqclkTFHFCMmk/LQ11KK /9UiCuIA8rBLtXA13FvE4TpdgbWG1r+DIre+CPggLPdDKviXNFgKppxmtPqkejOYJXQF 2p5enWwzOrBxh03tSnlH++u1S2lNDbzrF+Sk8iqeaeZLwHZDdwWBarccshwbbtG13Y9+ Y7zIK3khPxAuoU7Re1rvToKtwW1XXXe2w6VNKhB5XK/zhKTMdxi2gp20nC8SbQ3uy4RT 6tEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pW5sFrDbeVX26WrkS+PKzcHvaR9BQXLwgH6hOfMBAs8=; b=QYjKpFFSTaE8S8Dtxz0c8JpIqibl4gMwR/mHhujPlH+eCnhH6IzGWuFL64HniQaL+r VEUEWmIhJZ8yr8cqYot9lEECPNnaAHgnbHJE0JGfGYp6U+68heAfa9Y9CAV/0V/5uyhm XV+4TbcMF8Dh8cY26E+Gj/l41spHxDA8kthd16yKvyYrSOMPsi88b1DXr+35P9dIUySu yPxVAQ0OeqdW1EcjaUFBVw0FFghZg5MhpGtRhmnHl+8z5KS2JOvo9FpmvrdDFbJDTMfa rV7AzAwbr0iSakhzB5iESErk+9ciXdhzm37nvojYgMAM+XEiBB6XXyip791tXM76gAeo UIOw== X-Gm-Message-State: AOAM532r8p4BHpQkJW3Ngn61Vc0dPOcj+gxUSLZlbN6Zz77/a0rlhj8+ /B+eBOW2pFDN42Cjdkii2x0NMuJDuDTNdxiz8ro= X-Google-Smtp-Source: ABdhPJw0yZDppdWRfYrKZdMGyCex9aiYdvYaSLwFfMAmgT+Buse9PNwut1GZDo4jd5/1p4A8RTAPpMXIsl4rwAycl6Q= X-Received: by 2002:a05:6402:d4:b0:418:7193:da1 with SMTP id i20-20020a05640200d400b0041871930da1mr4877095edu.57.1647528885697; Thu, 17 Mar 2022 07:54:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 17 Mar 2022 15:54:33 +0100 Message-ID: To: Saif Eddin Gmati Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000fd3eda05da6b35d2" Subject: Re: [PHP-DEV] [RFC] [VOTE] Sealed Classes From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000fd3eda05da6b35d2 Content-Type: text/plain; charset="UTF-8" > > to me this closes extensibility in a hard way. > > This is not necessarily true, we have `final` in PHP which does exactly > that, but `sealed` can still allow for extensibility, just from a different > point, e.g: > `final` has the same issue to me: it's a feature of the language that would be better enforced by a static analyzer instead of a runtime check. This would work for me: #[Sealed(A::class, B::class, ...)] interface Foo {...} Then, nothing in php-core but a rule in SA tools to check that the semantics of the attribute are respected (or a custom exception to the rule when a user really wants to ignore the attribute for a specific class, being on their own then). Note that for `final` this is already common practice - using the `@final` annotation to express the intent that a class is final but still allow e.g. to generate a lazy proxy or a mock class (or any other need authors cannot anticipate). > Considering the `Option`/`Some`/`None` example above, given `Option`, now > you are sure that it's either an instance of `Some` or `None`, where > previously, a third type could exist. > > Authors previously got around this issue by adding methods on `Option` > such as `isSome()`/`isNone()`/`isSuccess()`/`isFailure()` .. etc > Or "instanceof Option|Some|None", which achieves something very similar to me. This relates to the paragraph about composite types in the RFC: most of the problems you describe for them can be solved in practice by introducing an abstract (@internal) class. Please note that I'm making these criticisms in a constructive mindset. I do appreciate that there is an RFC about sealed classes and that we can discuss if and how we want them in PHP. Right now, I'm not convinced we should add them and I'm trying to articulate why, that's all :) Nicolas --000000000000fd3eda05da6b35d2--