Re: [RFC] Draft - Closure self reference
| From: | Eugene Sidelnyk | Date: | Wed, 11 Nov 2020 05:47:12 +0000 |
| Subject: | Re: [RFC] Draft - Closure self reference | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112220@lists.php.net to get a copy of this message | ||
Think the way it is implemented in JS is better than
$lambda variable. At
least it doesn't have BC breaks (does it?)
On Tue, Nov 10, 2020, 7:38 PM Hans Henrik Bergan <divinity76@gmail.com>
wrote:
> something i'm missing from Javascript is the ability to give names to
> closures,
> this both gives closures the ability to reference themselves, but it
> also makes for meaningful stack traces, eg this is legal javascript:
>
> (function TheClosuresLocalName(){console.log(TheClosuresLocalName);
> throw new Error("look at my stacktrace!");})();
> - the name is optional, and only visible inside the closure itself,
> and unfortunately this is not legal in PHP, i wish it was.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>