Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127005 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 6B21A1A00BC for ; Tue, 1 Apr 2025 11:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743505967; bh=dkFCTacNQjxBaRh2pN3yo1EBgZgCoPn5y0bipmvjeQk=; h=References:In-Reply-To:From:Date:Subject:To:From; b=RGjNy1K1KbJh3u6d39x9LuOHl9ZgkRA3nqp4Rhx4aYwunbPXiv9u+wpIWTeO05grZ DaNtTwSQjsUDn7qCWX0jVjYkXHz16q9UfRihzmGR4USKt7LB7TdU2bh0XhdlD5fUJW dif3ivWrAotZ3duobwQ6OZhhNR0+KKUIi7yV8Y5fE+/4tdlNxdEuAagCONTkEkYVDi z0RpMSa8uDGZb03ye7WuHEOJgnK2uoT0j4glrB2Rdsnt0lo+Cc6jXfpoRsSOf2Ayc9 z2Nqd0Ydqb/5ktJnyQdO4mOYZf3tSJ/qM3XzsMqqN0xyE+o+gT9HI3dYV+yb6YDrY+ C/rmf5eSwFzUw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8FD181801DF for ; Tue, 1 Apr 2025 11:12:46 +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=-2.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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, 1 Apr 2025 11:12:36 +0000 (UTC) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6e8f6970326so49392646d6.0 for ; Tue, 01 Apr 2025 04:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743506102; x=1744110902; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dkFCTacNQjxBaRh2pN3yo1EBgZgCoPn5y0bipmvjeQk=; b=TOnqG2UAp3LQPZyXsf5BPboUvLLaWf3B+6cy5Ypqgiprj38rggk3VYG+PTG13og+vB FBV/r80lycHahvOhbEUm7wdZ/53ixIJsJNMKFbhATazCgQ5ypxrqNdmm9gNqbLh6hZ8M AWJlpq8k9hUO/XhZDn3zpaYclm5c46l43MYvWAyq9iEoFbaIIgWW3CeIwxnkjAAtKiSk pnxFyh36Ta/NPlhQJ90Aldw2niZdRZVmpXN6A5HrGm1EPCaQCw1gVfrFZtXqk2V2jDc7 SB0dQ1qVXt391u0x7o/487Fls8mDEYDo/URLCgu0jArdPGo1XHZ5De9zOHz09XzUnm2s aVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743506102; x=1744110902; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dkFCTacNQjxBaRh2pN3yo1EBgZgCoPn5y0bipmvjeQk=; b=nQkFOVHFHSw1Mn0GenYwQ9UaKw7rq4BOxPS9m3tmTM5AZpkGw3ODbkIHOWK68NoCAH xTANKr7qwuNJCZrzakvLb6Wi/5618rJjgIWV+9qfWaeb5sapHDyHvYZqu7Vlgixwzcsj 5AtDuWdL0B75o4DyKBt4AZ2H3LI0aIYiUli1FmXgB/AYTCboVK1nf0zfZZveAAdBwT3O NGX2WpnxPS1l/9cloHDrGtnfQdSZwdFOlLeCjgdSnspDGu7H7emjtreuL2YIREo8TmYo Uypqp/9rleSoHIeNIcOK4N7xDx8wseuCivd7gaCmA7zy69LPaxPwvx5gFNz12//xojgZ mq8w== X-Gm-Message-State: AOJu0YwB0fi8ZygTZZQY7aI+cBFkUuTt50hKpLx9AHbEgNLGda4RQkui rP7XCbaA2affVIeGnOwelCHT2WNzaUdDC1iDBZOl7H3sTZmIcpnr6JGTIex/b6U+uEwHkt9X4jh hYVuM+m6jvIToEri5hupk/24NCjskslp4ILk= X-Gm-Gg: ASbGncsHFA62NPXhGBEZha7JvHqXTB3VeSe9y5OVGSuxpDUlZ350oDYcMUHa+fBHthj Mx2A9i0qzkOGsPqS7zzaWYZYPGNwofHXNc9ihBO5xpYCWirg71wdjTLTy4unQO05RF1yH+eKC25 p1iLy0YXYo8zmy4c8XYhwbxed0M7Bw8wMEZWHk1MuggCSs8fANlxwkYoeTC5KikyMepUtBXA== X-Google-Smtp-Source: AGHT+IGU1K0rAHBo9C3c8npsVY5eMVx9cyJAhCtFlWkYl+Olq6ryJ6aNuawlJbLDf+6ZlOAblIA7mcJ2Wr32A95j+LI= X-Received: by 2002:a05:6214:f2d:b0:6e8:f433:20a8 with SMTP id 6a1803df08f44-6eed5f89595mr207944096d6.9.1743506102178; Tue, 01 Apr 2025 04:15:02 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <7ec4933d-0b9e-4c5a-bdb3-6a1a93c5ca62@varteg.nz> <87293ebfb73c8842e9aea2192df687e2@bastelstu.be> In-Reply-To: <87293ebfb73c8842e9aea2192df687e2@bastelstu.be> Date: Tue, 1 Apr 2025 13:14:51 +0200 X-Gm-Features: AQ5f1JqDbQeK87eVhl5VrFcy229erKB5QdgdPshgxDjSNd53vOwaiwQ9TOGLIoE Message-ID: Subject: Re: [PHP-DEV] Closure::getCurrent() for recursion To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) On Tue, Apr 1, 2025 at 12:40=E2=80=AFPM Tim D=C3=BCsterhus 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 =E2=80=9Coptimize DX=E2=80=9D for that case, sinc= e > self-recursive Closures are already somewhat questionable / rarely used > (though I think I've used that myself a handful of times in the past). I don't disagree. To reveal my ulterior motive: References [1]. References are used relatively rarely by PHP programmers, but they sneak their way into many more places in the engine than you might expect. They are also often confusing for users, bad for the optimizer, and make implementing some highly requested features (e.g. typed arrays) much harder. I started collecting a list of things that require references, and self-recursive closures is one of them. It may be an unrealistic goal, but if we ever want to even think about deprecating references, we'll need stable alternatives for cases where references are currently the only viable option. Ilija [1] https://docs.google.com/document/d/1DTi4DL6wLOpDhNlmtD-G4Xr-F9oq7cTG6ir= K7BPxllI/edit?usp=3Dsharing