Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126295 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 5BADD1A00BC for ; Wed, 5 Feb 2025 12:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738757661; bh=EoTiGIvtFDnP6BVzItM/mM9RK2eIcOm+RZgmoj5PHiE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=esV2UA3hTQneg0G8RdKod5ZhdvbXZHL5j8/kzb4DEq/+ld6ae2S4/8/HtvMcnt6MG 78i94WDwkcn+1bfaUpYiG2qm+amesCW5F2JdOM9QC/ndRoixtHRYV94xilwCe9fx+S SjuizKVBAoFuxSaYNsxaOpXFb06quoWgROqqMb7utFWm5qgRAnLQSnBdrKnARtVavI JVfEpTS/rTrl5t/1z6ZbFDu2KitYKaoSrLF8wQzh09lfXNgG5OEZIo4qh8xH6XZNzH MI+Mi6HBQioUqACKkirCtovZ1u+dnQFVC8f6pNvkqHaD3zfgSVAl9FImIprxEB0Iv/ W1ePP/CEN+/Sw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6151D180071 for ; Wed, 5 Feb 2025 12:14:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 5 Feb 2025 12:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1738757824; bh=2GnJLeAxQiLUpUfVW2hguNJxsItZZ1oDZhbFtnrj8Ic=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=hPRe0VIyR0fxqJn+5x2BRxQqyaAQiMJUqwppN5+DHcyZVMqf4qC6x/CkBIzRaKaiP nIZS/SLPmdHOITAIFoy4AoSIaruk1GkfxPGO+0vvHewD0Tz7Rm/MA/ZY1HgITipyOt CT0ob3ofbbXQCDK1xgplQxYnRbCQcEzZTo55ANFsPB9YoPcx6QTRN5zu68rXFX4+ui lUQMf3OsPYyD+368io8GmKns/TselI+bSEbT+va+zB+BPZ0wa/DBUXKBfFMA0w+ObO Pw8qP5e8rJPuvz25O4KeDGObUWZfm0HBww9BbJ0UKP/pw1dgMBZUPyKZxYj/9F8WTU 2hxxDPiktvSNQ== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 05 Feb 2025 13:17:03 +0100 To: Rob Landers Cc: php internals , Volker Dusch Subject: Re: [PHP-DEV] RFC: First Class Callables in constant expressions In-Reply-To: <9d2d54af-f705-4c74-baae-d05d09a1f1e9@app.fastmail.com> References: <2eba1ea4cffa751e6a5f325b972e86b5@bastelstu.be> <9d2d54af-f705-4c74-baae-d05d09a1f1e9@app.fastmail.com> Message-ID: <265b1cbcfe341f29eb3dc81b4067d258@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-02-02 15:35, schrieb Rob Landers: > My only concern with the RFC is something a bit silly. If I understand > correctly, this will be a constant expression: You understood that correctly. > It is an incredibly small inconsistency (imho), but other than that, > ship it. I wouldn't call it an inconsistency, it's natural that the allowed expressions in a constant-expression context are limited. This limitation is mentioned in the second bullet point of the “Constraints” section: Only the "basic form" of first-class callables is supported, mainly to keep the implementation simple, due to the limited usefulness of the more complex function call variants when limited to constant-expressions. As an "escape hatch", it's always possible to wrote a proper closure that just forwards the calls to the desired method. It will also result in a useful error message that is consistent with dynamic new-expressions within const-expr context: Fatal error: Cannot use dynamic function name in constant expression in test5.php on line 3 and for new-expressions: $ cat test5.php