Re: RFC [Discussion]: Closure self-reference
| From: | Alexandru Pătrănescu | Date: | Mon, 05 Jun 2023 04:08:46 +0000 |
| Subject: | Re: RFC [Discussion]: Closure self-reference | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120528@lists.php.net to get a copy of this message | ||
On Sat, Jun 3, 2023, 21:11 Dan Ackroyd <Danack@basereality.com> wrote:
> Hi internals,
>
> I'm now opening the discussion for the Closure self-reference RFC:
> https://wiki.php.net/rfc/closure_self_reference
>
> This was previously discussed as a draft here:
> https://externals.io/message/112216#112216
>
> Thank-you to KapitanOczywisty for the implementation.
>
>
Hi Dan,
How about a keyword/variable to the current executing closure that works
also if you refactor it to a function or a method.
Just like self for a class we can have a keyword like fnself or a variable
like $fnself that is automatically available inside the body.
For a closure it would be the closure itself while for a function / method
it can be even just a little syntactic sugar to functionName(...) /
self::methodName(...) (not using polymorphism intentionally).
Maybe we decide not to implement this right now for functions/methods but
we can at least choose a name that has a wider meaning.
As we are talking references, I think there should be a mention in the RFC
about how GC will (not?) be impacted?
Is the closure reference count incremented just when the Closure execution
starts, with no impact on GC?
Regards,
Alex