Re: Generators in PHP
| From: | Morgan L. Owens | Date: | Fri, 10 Aug 2012 00:53:34 +0000 |
| Subject: | Re: Generators in PHP | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62111@lists.php.net to get a copy of this message | ||
Mike Ford wrote:
The signposting needn't even be as in-your-face as a generator keyword (either instead of or in addition to function): I could get behind a variation such as: function f($x, $y) yields { ... yield $z; ... } Or even (stretching a bit to re-use an existing keyword!): function f($x, $y) return { ... yield $z; ... } Although I like the concept of generators, I would be -1 for any implementation that doesn't differentiate them in some way from regular functions. In other words you want to have return-value type-hinting _in one specific instance_: when calling f() returns a Generator object.