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::cu
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.
Kind regards,
Jorg
On 15 April 2025 00:01:18 BST, Krinkle wrote:
>Eg:
>
>$a = function ($a) {
> $aFn = Closure::current(...);
> $aFn(4) === Closure::current(4);
>};
I think there's some confusion on this thread; as I understand it, the proposal
is not for a magic function to *call* the current closure, but a w
On Mon, 31 Mar 2025, Jorg Sowa wrote:
> I thought about edge cases and what the desired output is with nested
> closures?
>
> Example:
> $a = function (int $numberA) {
> $b = function (int $numberB) {
> if($numberB < 10) {
> return Closure::current(10);
> }
>
Hi
I looked at it earlier, when you opened the PR.
I also remember the discussion from the past.
Your PR is super logical, and a super easy implementation.
Language change seems unnecessary indeed.
LGTM, ship it!
Kind regards
Niels
On Tue, Apr 1, 2025 at 12:40 PM Tim Düsterhus wrote:
>
> If you are at the point where you need mutually recursive closures,
> perhaps you should just use named functions / an anonymous class. I
> don't find it useful to “optimize DX” for that case, since
> self-recursive Closures are already some
Hi
Am 2025-03-31 22:38, schrieb Ilija Tovilo:
Do you have thoughts or concerns with this solution? If not, I'm
planning to merge it into master in a few weeks.
I don't particularly like this kind of “magic scope / backtrace
introspecting” functions, but it certainly is a pragmatic solution (a
On 2025-04-02 00:14, Ilija Tovilo wrote:
On Tue, Apr 1, 2025 at 12:40 PM Tim Düsterhus wrote:
If you are at the point where you need mutually recursive closures,
perhaps you should just use named functions / an anonymous class. I
don't find it useful to “optimize DX” for that case, since
self-
On 2025-04-01 22:02, Hans Henrik Bergan wrote:
@Morgan $second=function(array $a, callable $first){...}
>
This is just as effective as it would be for any use()d variable, so why
do we have use() again?
[Note: in my original mail "$left" should of course have been "$first",
otherwise there
Hi
Am 2025-04-01 12:32, schrieb Morgan:
This is just as effective as it would be for any use()d variable, so
why do we have use() again?
If you are at the point where you need mutually recursive closures,
perhaps you should just use named functions / an anonymous class. I
don't find it usefu
@Jorg the desired output is 14.
@Morgan $second=function(array $a, callable $first){...}
On 31/03/2025 21:38, Ilija Tovilo wrote:
Hi everyone
A few years ago, an RFC was proposed to introduce special syntax for
self-referencing closures, mainly used for implementing recursion.
https://wiki.php.net/rfc/closure_self_reference
The proposed solution allows specifying a variable that w
On 2025-04-01 09:38, Ilija Tovilo wrote:
> Hi everyone
>
>
> This is essentially already possible through a by-reference capture.
>
> $fibonacci = function (int $n) use (&$fibonacci) { ... };
>
> This cannot be a by-value capture because by the time the closure is
> created and variables are bou
Hello Ilija,
Nice addition! I thought about edge cases and what the desired output is
with nested closures?
Example:
14 matches
Mail list logo