Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127113 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 B356C1A00CD for ; Tue, 15 Apr 2025 11:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1744717310; bh=cLV3qHswN4/+NX78DXMIuCuOkynhNdeISSjwAYhg/FA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=GkJ6Yv+FwQtMutnxCxQ3m4BKnKIPgeOOC0CkwzcIBT4Qj0eekowEVKAYESLdZN6qN lVgypEHaMN4HgMJsIbq5TLPzYHAqZYEpSnvKF/kGy14RSrUFPXYqC8B0URx3JT9PT2 CZSszG19EKiGaKwaV+xyIwSWz/giXRzTH1mCqwImKfYpguUSXLncmgwEdkmNoVVjuO DTgHthrMW+Cd9Tt1C46SNM9+pGIUDT8kZPRnFfUNpRiNrx2ym2W9GUucUKdK0yziqS XIWs8GxpvW6t5QEZYUdfvCxQnknnRnGejWoVvdUHFIfAsnatJZWG7bKOvuWk5IvS+c Be+pZdTnSOang== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7142A18006D for ; Tue, 15 Apr 2025 11:41:48 +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.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 ; Tue, 15 Apr 2025 11:41:43 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 100AA254028B for ; Tue, 15 Apr 2025 07:44:05 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 15 Apr 2025 07:44:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1744717444; x=1744803844; bh=30hSBr00JX462UaXr1nqczXY09940AGOxA7O4a9gyK8=; b= vl0VIHnTJRWQPpy2p/PncK0a1465KEWrrWQroz+mlYt0ZqsPfKT37DUcglU1tg+X 06cFawqDpP5LDKfL14L8/1Er7blZjalOXfTMk2uOZDjHHFNrYeuuuSbJEkIYHCyq fgAJWIrCAOxu4i8DRhzqBohVO/wm2z410pdWnCz9AW2Ywmly4e1AMNolLw3MALH7 2jDFmozI6W7QpvMRIWzAP3TNpTI26wgDnnb8ImGJnRSylLuUDuKyF2GwTOMVRxIm +D71aQQpt5ggmgi7kzpN/dzQ1jF9Gxbir4HZBhqxqQ75PQa+0uAX42/AnTNTEjXM IXvxpO74hcqaw8UMVT1fmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1744717444; x=1744803844; bh=3 0hSBr00JX462UaXr1nqczXY09940AGOxA7O4a9gyK8=; b=VyWDKcTklGBGeZxE4 4uhDKZbU1avU1W+udxa00AKnQynOm7Tu8y1z88tqNqysiLTNP1wwb3t85PSimmk+ wqv2Zh6Qqnzp2Ix5rWoUzdV2CtEHYLPHNHVvz3oTd1tapaQtmRx3awE6ABdwBc6N VnOgeRW4b+jgkKCQttGWjSXDYE5UKlZD53FRt9qsGLXkTmQX5iTOoPUpUu74USbC 4tJjEsowHxy/YfCHs6A9WmYfCgD9NYKEj8u88H7Zv0riGgCRjcHcOnlej4vYxhQ+ GoLijj4TsyqlmbkpekpIzGWWdXzLkypXiBscUYXXGMme3vUQYxg7HSx2r0qZdSK1 RPUzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvvdefgeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeffkeevudffuddvheejvdefkeelfedtudegfeehjeduheeg ieduffeggeegveefheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 15 Apr 2025 07:44:04 -0400 (EDT) Message-ID: <2860c886-3ce2-4b6c-8272-82a4ff782a83@rwec.co.uk> Date: Tue, 15 Apr 2025 12:44:01 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Closure::getCurrent() for recursion To: internals@lists.php.net References: <933A6600-F9E3-4335-B496-972EB0037CD2@rwec.co.uk> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 15/04/2025 11:49, Jorg Sowa wrote: > I gave this example only to point out that this case should be > mentioned in the RFC to dispel doubts what's intended and eventually > put such test case into the PR. Sure, but there was a mistake in your example - Closure::current(10) should be Closure::current()(10), i.e. "get the current closure, and then immediately invoke it, passing 10". More readable if you put it in a local variable: $a = function (int $numberA) {     $b = function (int $numberB) {         $selfReference = Closure::getCurrent();         if($numberB < 10) {             return $selfReference(10);         }         return $numberB;     };     return $b($numberA) + $numberA; }; var_dump($a(4)); The local var $selfReference refers to the same Closure object as the outer var $b, because that's the closure that's "current" on the line where Closure::getCurrent() is called. -- Rowan Tommins [IMSoP]