Re: PHP True Async RFC
| From: | Rowan Tommins [IMSoP] | Date: | Wed, 05 Mar 2025 23:50:13 +0000 |
| Subject: | Re: PHP True Async RFC | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126590@lists.php.net to get a copy of this message | ||
On 05/03/2025 23:10, Rowan Tommins [IMSoP] wrote:
This is roughly what happened with Closures themselves in PHP: first, decide that "$foo = function(){};" will be valid syntax, and define Closure as the type of $foo; then over time, add additional behaviour to the Closure class, the ability to add __invoke() hooks on other classes, etcSorry to double-post, but Generators are probably a better example: you can write "$foo = yield $bar;" and there are well-defined semantics; on the outside of the function, we represent the state as a Generator object, and make it implement Iterable to explain how foreach() works; but on the inside of the function, it's pure magic: $bar is passed into an invisible channel, an invisible continuation is created, and when it's resumed another invisible channel passes out a value for $foo. -- Rowan Tommins [IMSoP]