Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126270 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 4BD3E1A00BC for ; Sun, 2 Feb 2025 13:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738503351; bh=wJ9FLVoqm/OHSMm116U1/RanXVDloOMsu+EYfQ4aLrk=; h=Date:From:To:Subject:In-Reply-To:References:From; b=cJ5l4S9biEv3/Cu3GGiCbcMbmp/lUut0PwykY4XahZebwo3lQT9Luhvy094LAcqyx 6gWtrFcjvfYHaILZ/Xl1N1NJCbtv3arwCbCtjsNCXrQaRWnqHvwp40ZGURTasVj54K 4aB0e94Uxbx17WysH9AVd+piezn/tOLNGNWmcPdmlzK8pAFu4ReMXpapFZYgGzXeD1 YiNh9Bqge0e4XWAPsfBPZNghqZH+PCL2sRQKxyZYiu1N+XqrzclbeyLs7jsw473GwT YeBp7LxMgdFSFa72/Ntf6tWnby9VMhIeU0+qU7rbQzM3rZnQybsAGt0L7nvJDNcQ0T yXZHBpm8pnJgg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8176D180511 for ; Sun, 2 Feb 2025 13:35:49 +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.6 required=5.0 tests=BAYES_50,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 ; Sun, 2 Feb 2025 13:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1738503512; bh=OlyDfi+E6ivfUwt/mRpMn462hskQZ3D0vjgjmQs0jJg=; h=MIME-Version:Date:From:To:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=DjIlyOGVTSxBeey9+THF6ZFJCuTkCkMJpuY1n99JxG1S/4z2etNPcBH/G656cd+Sr iYKe1+bqZ5H+sYgKdYuRqWnky4W67hNhLhaJq4H5df94AvThqbWxwTmfUXlesgCD7K a7UkB4MNubs6kSaoo0gWNWANA+8oMbnDT7nhPCVovGrqsICESQUzaCz+7qfxP/YpSP NGH7TGzNlwc41P8I6d4J6jhr3ZPzvFSIWJLDCtMxTCmLarorXekUWgW7nrUcbFnlQm QYEuWZOhgqDHJq4dUUU1x1cazRRIEZd/sl/9pEz46jag8L98sg6Apnp4JpIyikHdwM vDs3/BMEQsh1w== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sun, 02 Feb 2025 14:38:32 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] RFC: First Class Callables in constant expressions In-Reply-To: References: <2eba1ea4cffa751e6a5f325b972e86b5@bastelstu.be> <1c7c7c0075b37a8909faa5cf352d57a4@bastelstu.be> Message-ID: 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-01-31 23:36, schrieb Larry Garfield: > Purely out of curiosity and for educational value, what was so > complicated about it? I would have expected it to be straightforward. FCC internally are effectively treated as function calls with a funny parameter list. This means that all valid ways to perform a function call are valid ways to create a FCC. And likewise do all constraints of a function call also apply to creating a function call. FCCs in const-expr need to replicate those semantics as applicable. For us this means: A FCC in a parameter default value behaves, as if the assignment was the first line in the function body. Likewise must a FCC in a property default value behave as if it was assigned in the first line of the constructor body. And then amongst others you have the following (edge-)cases to take into account: - All kinds of expressions can be used as a function name (this RFC excludes those for simplicity). - A FCC can resolve to a dynamic function when __call() or __callStatic() is implemented (this RFC excludes those for simplicity). - Static methods can directly be called on a trait (this is deprecated, but supported by the RFC). - Calls to free-standing functions need to take the global namespace fallback into account (which will be cached for each individual call, which has funny effects when the function in the same namespace gets defined after some of the calls already executed at least once). - Visibility and names needs to be resolved correctly, including references to `self` and `static`. For regular closures (i.e. the first RFC) it was as simple as: Disallow `use` and require `static` and you're done. They are much less context-dependent. Best regards Tim Düsterhus