Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118071 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21219 invoked from network); 23 Jun 2022 10:13:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2022 10:13:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD7381804D0 for ; Thu, 23 Jun 2022 05:03:30 -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, 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-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 23 Jun 2022 05:03:30 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id 9so10223118ill.5 for ; Thu, 23 Jun 2022 05:03:30 -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 :content-transfer-encoding; bh=+J6lAh7R+Muzug90K1P0C1+J4M5WI6I8fJcacCRy2y4=; b=SP9d0RAHN8DtHWPxCzTLGAl+aXLiFRShEPIFpKNH1+zitVhyDEAsHMkCUSparZAzYY s0TVmmQf6b2nnreOvb7Yfw+UD5dhU7lxLrTZIBnYgJmt/PyZ1MO47u8aca4LSPnJ/5T7 6Z4yiLk00hL4OhueJRc5NIx0GMP6uLdaAytDssLuopxRlfsAQbdtsKr4P3vm8RIdkG/x bQWzF37BjiP/pAIubVCtfg/2AzXz3K0RntpsBwfSJsk4fDQLygiJfYxv/KJeU5h/vq+O 5Ki0Zyp0mAX3L/CRWkbAGC4PeAEPBnuchRFuQDUiwHbnXr77tbQf1BEuG80TMrESFlNO xAHA== 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:content-transfer-encoding; bh=+J6lAh7R+Muzug90K1P0C1+J4M5WI6I8fJcacCRy2y4=; b=ksaTUzmhyCWS33qNpivpIneJ7E5SJ3axxFAK4mTei//mx3zOmbm8rAzaz/MhYaiJlf NgTC/oXmADgDMBOfteia9wFehrnsPQ3FtdYftIHdLBol23pzqtMedemctV1wETFpGXHc yyqg02jlUYtG04HQbg4XSkT/L50ATh3eCFcJoJ14wsu+TKQ8B0nyZ3SITZbSrB848SDY SzuHlDM8Z4o32Ht015YvV8Oh7Etlohir3aPpJQuSj95sGzO14e+udq3zn5aqo0SAJSXT DV9Hug6BMqJvsXwd0r+QurAqugaXJEcFi9HQ1F1q/r9jFs1WYlT1sC5nUEypochUZVkR IVrw== X-Gm-Message-State: AJIora//2T2IwPQW7L4cc+/XIGZLyPPlq7DZtGznvK2+GjfUyF0MuJ6Q qzHmbJfVKGDz7ALuaSOaQfL7vGJ727GXGG4OqHn81bBM+5oWPw== X-Google-Smtp-Source: AGRyM1uu1Otr89w7NuISVFReuloItr0iDivNkLBPRPdZMpJBX/Rq9ez2/vGgVN0IHyj8bUyzXNXibiBXT5PcCEhvHqc= X-Received: by 2002:a05:6e02:1ca7:b0:2d3:efd2:f34 with SMTP id x7-20020a056e021ca700b002d3efd20f34mr4906606ill.259.1655985809482; Thu, 23 Jun 2022 05:03:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 23 Jun 2022 14:03:18 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi everyone As foreshadowed in the last e-mail I updated the RFC to restrict the fetching of properties to enums, and the PR to match it. Unless there is more feedback I'd like to start the vote early next week. https://wiki.php.net/rfc/fetch_property_in_const_expressions --- Hi Claude > I feel that, in any case, allowing unrestricted fetching properties in co= nst expression in is semantically incorrect, because properties are fundame= ntally mutable. I am not speaking of creative use of code in order to achie= ve the effect, but of the regular semantics of properties. > > For me, it seems reasonable to restrict the feature to readonly propertie= s (including those of enums), because those are effectively immutable by de= sign. I thought about this option before the last e-mail. Unfortunately since readonly properties can be initialized after object construction the same problem arises. You can find an example here: https://wiki.php.net/rfc/fetch_property_in_const_expressions#allow_all_read= only_properties --- Hi Alexandru > I really think we should have the same limitations for "->" and "?->" jus= t like we have for "new", with the same reason that that was disallowed. > That would mean not allowing it in the default values of a property. > Maybe I'm missing something but it looks like this was the plan all along= as you don't have any example that would include that, neither in the RFC = or in the PR tests. It was always planned to allow -> in all constant expressions. I added tests now for all the constant expression positions. Now that only enums are allowed I don't see a big reason for restricting the scope any further. > An option to limit it to enums in the other 3 places, static or instance = property initializers and class constant initializers while allowing it on = all objects in the 4 cases where new is allowed. > > Or yeah, limit to enum in all 7 cases, if that is a lot simpler. > I wouldn't prefer it as I still have cases in mind where I'm not dealing = with enums but it's your call. I mentioned in the last e-mail that there was an additional problem regarding caching of constant expression results. I added a section to the RFC (https://wiki.php.net/rfc/fetch_property_in_const_expressions#cachi= ng_of_constant_expression_values) in an attempt to better explain this. I would rather delay support for other objects until we're confident we have a good solution and haven't missed any edge cases. Regards, Ilija