Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120527 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20209 invoked from network); 4 Jun 2023 22:42:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Jun 2023 22:42:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 12373180089 for ; Sun, 4 Jun 2023 15:42:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 4 Jun 2023 15:42:40 -0700 (PDT) Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-55554ab909cso3039334eaf.2 for ; Sun, 04 Jun 2023 15:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685918559; x=1688510559; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=i0SiXqr1Mi7gFsVf2tHWYVNE3XIf/WFkBGFx6tw/pMU=; b=DWdcIJFrP08AFxZ06XCT1eFB81evrOGwuylypKaFLt7oW+AtiO5js8MbQ58ga1odO6 dLsO8zDVrLxC+p1JbysCgRrNC3i0XDX94wdXXvNtHbEqeQblymz9D9vfBczZMHLjFy6V opprlgVlAUoLhXdkOUlgOVuG2lKNfMW89H7GkxO86jUDPhflgFTavNQP5Z8FGd2DVQZ0 Y199OUy+gw3gmX/skqeeoqDrA+xd/MtKbL7MD9VEoUATbnnlhzTYzkF/CMsQR0AXHOi0 WLN58fPr5fFQ3MQqFpu4jbhtXIGlz1PJSndGcTEYXPVAputOa/PK5A9yl99ZsT5VaSJw wNSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685918559; x=1688510559; h=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=i0SiXqr1Mi7gFsVf2tHWYVNE3XIf/WFkBGFx6tw/pMU=; b=BkuWvJHm3zzQ5cVkveHMjZTRzhg9RrgWGCVOGlYaMp4XxbmGjpamDdVW4V37SDz0cD oBDoQoEIt6US+S6vr/cpWOoNMOWqBapoG/IsFrH8SEGLt/K+UaKGKu1WqPRZpGQOrUzt EOq7g/RecZ9vy4tep37vIb50Xh40jWJijPY5M5hp9u4KEVZIAP4q25Vv2BJO+HLTI0oP tCUX5/cznwn7uus3gunNhcJBhh9VtSk3k3w7UrOaclezEK2KhEC4FVF/A9SN/xHeE8dt e4uYZEQz7t+Cbv092M8P53zPiZ4ZTWeZeaIhSMewO+/B37WWQmtOKV7EBf8z6C8tbjgG seGQ== X-Gm-Message-State: AC+VfDzaEcOey+c0ErC4QORp4IxoTDZUiv87HB830fAg0efyfVpIvTj+ g+Mar6QYrN1faKoM1/Hizx+WO9soSRzHMrjQ5Z647zeL X-Google-Smtp-Source: ACHHUZ6L7xCQO4SxARmkIz7Rya3JcNDI3dO2viJ3yxX1OjPBT8xYkOlhJeBSeYzy0zvuMvtTejtUSb8vyObecFTXPKM= X-Received: by 2002:a05:6820:3d1:b0:558:b7e5:1dd0 with SMTP id s17-20020a05682003d100b00558b7e51dd0mr1622183ooj.3.1685918559563; Sun, 04 Jun 2023 15:42:39 -0700 (PDT) MIME-Version: 1.0 References: <647C701E.8030104@adviesenzo.nl> In-Reply-To: <647C701E.8030104@adviesenzo.nl> Date: Sun, 4 Jun 2023 23:42:26 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000dcf55d05fd5580b0" Subject: Re: [PHP-DEV] RFC [Discussion]: Closure self-reference From: davidgebler@gmail.com (David Gebler) --000000000000dcf55d05fd5580b0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 4, 2023 at 12:06=E2=80=AFPM Juliette Reinders Folmer < php-internals_nospam@adviesenzo.nl> wrote: > When I read the RFC, I keep wondering why new syntax is needed for this. > Isn't this a solved problem with the solution being "use a named function= " > ? > I think that's a bit harsh - couldn't we say that about any limitation of closures, or any proposed improvement to closure handling? "Just use a named function" doesn't seem like a fair critique when the usefulness of closures isn't in question, or the fact that people do use closures. > Might I suggest to expand the RFC to answer all or at least some of the > below questions ? > * Why is a recursive function call something which should be supported > at the language level for closures ? > It seems a reasonable expectation that the functional capability of closures should as closely match named functions as possible, doesn't it? Or at least that whatever limitations they have don't lead to runtime surprises like the example given in the RFC. > As for the syntax choice: it seems like the proposed choice is largely > arbitrary and personal to the authors to go for a "languagesy" syntax. > * Was any research done on how frequently this is expected to be used ? > * If so, does that frequency justify the need for a change at the > language level ? > * Was any research done to find out syntax preferences from anyone other > than the authors ? * Was the impact of introducing (yet another) syntax level change on > static analysis tools considered ? > I think there was a fair bit of discussion about syntax choice in the previous thread (which was a long time ago now) but the point about impact on static analysis tools is valid and relevant. That said, there is an argument that it's for ecosystem tools to adapt to changes in the language, not for the language to orient itself to the convenience of those tools. Still, I suppose we do have a special case with static analysis tools in particular over other stock userland libraries, because these tools in particular serve to fill gaps in PHP's limitations as a dynamic language, so I think your point about reconsidering syntax choice in respect of making adaptation easier is worth the RFC authors considering further. I think for users, the proposed choice with the "as" keyword is the most natural. A recursive closure is probably an extremely rare thing to do whatever way you cut it, though, so if the syntax for users is a little uglier but it makes some other aspect such as what you've raised above easier, I can see the justification for choosing one of the other options, probably a constant like __CLOSURE__. Anyway, although I can't vote, +1 from me in principle on the feature, syntax TBC. It closes a very small gap but a gap all the same. -Dave --000000000000dcf55d05fd5580b0--