Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119714 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23616 invoked from network); 15 Mar 2023 18:10:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Mar 2023 18:10:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 71A411804F2 for ; Wed, 15 Mar 2023 11:10:26 -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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Mar 2023 11:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1678903823; bh=z/VyL3DiC3IySNP7x3S09JKWZRC1nmIjxWvrL/CJjA8=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=Q7X/QgGurZs+ej1eR99ca/zmQReFnIw7CWTWY5kE1BLZgOVHiUbNRy14I4RLFG2KW IBOTfZnDCpRHIMGBuM+y3VdFAF8XLPG7iDw4z+c2BcBaRfr5v4LN4kQb8gvEBrZ2+J T+rdQycGrZkvjmMe39IkJCZx8jIt/5Og1tpWeHxHu2QR043tetOxHuyp7qGQjNNDy6 oelpCfPrgpXfhSdby2WzCtpi8eVwslwXn4eXz/Z2ksujlDC6bL/T2c4Runo5j+8w4D Hh1MJjUWPpM1mLwDX8lWgfUOXFqc6/fY2l3MD/IZRjRAyDVVZ/du5TttVEMN5k7r6O ugxQXz2pc5WEA== Message-ID: <684c1457-16e1-1cf2-b005-b273ff7e4929@bastelstu.be> Date: Wed, 15 Mar 2023 19:10:22 +0100 MIME-Version: 1.0 Content-Language: en-US To: internals@lists.php.net References: <57ed96c2-0547-c905-1c6f-7433ecb4a1b5@bastelstu.be> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC][Vote announcement] Arbitrary static variable initializers From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 3/15/23 18:21, Ilija Tovilo wrote: >>> https://wiki.php.net/rfc/arbitrary_static_variable_initializers >>> https://externals.io/message/118976 >> >> There is an unresolved "question": >> >>> Side note: It's been suggested that expressions that can be evaluated constantly continue to do so. This would mean that some expressions in getStaticVariables are evaluated and some are not. The upside is that this would avoid the backward incompatibility. I will check if this is technically feasible. > > Ah, thanks for catching this. This has been partially implemented. PHP > will attempt to evaluate the constant expression at compile time. If > successful, the value will continue to be available from > ReflectionFunction::getStaticVariables() right away. Only when the > expression isn't known at compile time (including class constants from > other files) will it contain null until the function is called. This > reduces the BC incompatibility but doesn't completely avoid it. > Using Alain's example of static variables that depend on each other. For the following: function foo() { static $a = 0; static $b = $a + 1; } The value of '$a' is known at compile time. Is the value of '$b' also known at compile time? It might make sense to include that as an explicit example in the RFC (examples are cheap). Best regards Tim Düsterhus