Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125875 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 6A9F51A00BD for ; Wed, 30 Oct 2024 08:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1730275442; bh=42nVLkkxrl93XO5kyeCT004tyL1REw1C5M5SCyhvCvc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Aoz8kF83hSBCdYAMAAN6gNZ7NUmt2x78WWlExpNMzW1dMb5ackTaWOvfUZyMOHeYC gld4TDHTglAVPjYt9mUi4af/E5/RregJe5no9xLbaaxylfvwckDsb1uOen8yhY3Xym h+K6dtw6eHrVxbKolZ9oxL8QdNu9kite27cpAMScy5Zxmg3M19DulU/CagKLxSww2u 3t+abIPSCit+OfL2pHL+yzgU801mayO40AQxjeXiCEWofIOWK4jzSNm1SisKrlhSMM anB9XMTlOeMjlMH2shQEYHi1NDtOkEaV9aXQE2H0IL58jTaB46vi513lS9VPGXcZpy eHHPv2av1Vq8g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C28C318004D for ; Wed, 30 Oct 2024 08:04:01 +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 ; Wed, 30 Oct 2024 08:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1730275291; bh=raIW5zipqu/12ThQZvjd0j5vOV1nhKg4SpWbwJy34WY=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=R2zEXcXoPMsvy8LjL0dK5wkgC5/DKI5jkJ+WXOaeVP0T//RXae3YCDTFcV6g/prRC LfnPsr5obJtf6owAR8zNuY/lWCPQt0rpozrtU6klQnF2prVJiAdmQoua8c0QuaIhU/ T6Uabd24kKdwG9y6gHWQlidonkz7u//6bCy765FxnFIBpEbpf0mviQp9z0qEu/gbWb 5Ph8U0XAfPW+XGcIP8MkFXQKG/Hu4+eBfN3M9ABQYJQ+mZmqkq5nKky3CffO75tkAz gCMiSxo9J64EfbiLc8/kPGzXxWK3k3mxXrsb+D4lYAeq62Ph4ewDC6ttww9x/Q80d/ IyYUsaOv76Xng== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 30 Oct 2024 09:01:30 +0100 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] RFC: Support Closures in constant expressions In-Reply-To: <3b458165-406c-4b70-97bc-6e98d6c44c72@app.fastmail.com> References: <15da4c13445d7e9c9d768c60c19768d4@bastelstu.be> <3b458165-406c-4b70-97bc-6e98d6c44c72@app.fastmail.com> Message-ID: <6f39dce9e6b0579baa51bc84cb8140b9@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 2024-10-30 05:25, schrieb Larry Garfield: > This seems like a good idea to me. My only real question is why we > need to forbid short-closures. I fully agree that capturing variables > for such functions doesn't work. What I don't understand is why that > precludes short-closures. Is it not possible to "just" say "there's > nothing to even capture in this context, don't try"? (There may be > technical reasons for that, but I do not know what they are and the RFC > doesn't say.) It would indeed require some special handling to disable the auto-capturing in the code. This would be solvable of course, but there's also semantic ambiguity, because users reasonably expect short closures to perform auto-capturing: [$foo, $bar]; var_dump((Closure)('bar')); If this would be legal syntax: What would you expect to be printed? Best regards Tim Düsterhus