Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118067 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88677 invoked from network); 23 Jun 2022 02:34:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2022 02:34:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5EBEA180211 for ; Wed, 22 Jun 2022 21:23:49 -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,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-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 ; Wed, 22 Jun 2022 21:23:49 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id sb34so9388312ejc.11 for ; Wed, 22 Jun 2022 21:23:48 -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=bcgOSbtjD/L4yj/i9W1lMQNW7naHEANa26YOWum/shw=; b=ekSCtFzSIjoevG21+QXkQBTz36IRC9cUzZY21Tf7Ot+VvMzrq7JvyMBLw9yXo2WwsD oz32LAgRRScHqwTtwO3NvxafG2JEXbZWKrx8V/5tXliToXhmkW3Fv6Bo3/OYkt5kS9BJ cLTwT8ZsPsxFMrisG0WLTcQ74+/iCjYybPbmO4/YgLk0mN7ayohd887JeQ2UmlUFSEFA k+5ChzYAC3T+dBhHV4V6oup1EXRYyoY4r4OngJP60IFyTIOwuk/Urc+T2AoDWwZVaNR+ eyMQPxlyVSlY6VkZ5gmAbFG75CdDSUM61wclf4emIDLh48U4hgZGBe3P5MKN2qsIDecr srfQ== 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=bcgOSbtjD/L4yj/i9W1lMQNW7naHEANa26YOWum/shw=; b=Fud1AAOz+zs/DknmSfb8vFvUg0LAsc+65zW91C8LNA2+52UOl8vxE0aSMGsYOQtoY0 qA7s8d0zSpK4QEdeDIFSmQfQD+1NOpkMuunFhe00W6FhaOFyIJJb5ggV2+94BFOoK38o rWrvJr3YhQOezQa/nZsTZhoSgztGhhn3r9V/gB0W5qheTzXSBqodQFb32+7FeUJ1tJ+k lfzRWjXjHsGJNA+1peertYq/ByMHISZnJYgG0jfoZ6pXP7A2RTYVPsG6vE6SuAoDlcUA 5KhHZeLvNoa+OHSFx12hB5rTE1tZABbLX+soLJ5EKScr48zphkX+3vocNlvzbVm4ArFb KQOw== X-Gm-Message-State: AJIora9zq48wM5BaTdGQ8l2iGwmtsyK8UmeGlN2eb7lc3nblOBbade9X JOjpsyjpHjnZkIT6ePPzDAVzPipzkzSf2o3+BrBqa6qc/5VSBA== X-Google-Smtp-Source: AGRyM1vJ/zQBgz9myN/WGDKJeZbSPFPbwE31w8jkktGjLBEpNjnqQt1EpJJwfCuEHsyzxtKYBWUSu/iu3R1o/OrASIo= X-Received: by 2002:a17:907:948f:b0:722:e90c:6bc9 with SMTP id dm15-20020a170907948f00b00722e90c6bc9mr6205822ejc.180.1655958227674; Wed, 22 Jun 2022 21:23:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 23 Jun 2022 07:23:30 +0300 Message-ID: To: Ilija Tovilo Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ec6b6005e215d10f" Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000ec6b6005e215d10f Content-Type: text/plain; charset="UTF-8" On Fri, Jun 17, 2022 at 1:46 AM Ilija Tovilo wrote: > Even without __get the property of an object referenced in the LHS of > The engine evaluates the default property > values once for the entire class and then copies the result whenever a > new instance of that class gets created. That means further instances > will use the out-dated property default value from when the first > instance was created. Similarly, function default parameters get > cached between calls. We could evaluate the constant expression for > each object instantiation or function call but degrading performance > for an edge case doesn't seem worth it. > > Hey Ilija, I really think we should have the same limitations for "->" and "?->" just 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. The only case you mentioned and that's only in the RFC itself, not in PR tests is the class constant for enums. I'm not even sure that is working with the current implementation. IMHO, allowing the fetch property operator in the 4 places where new is allowed would be a simple good step forward. There was the discussion where allowing it in attribute arguments is important for allowing cross boundaries transforming from enum to string: https://github.com/php/php-src/pull/8825#issuecomment-1161735119 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. Thank you, Alex --000000000000ec6b6005e215d10f--