Re: Re: [PHP-DEV] [RFC] Generators

From: Date: Tue, 21 Aug 2012 23:38:54 +0000
Subject: Re: Re: [PHP-DEV] [RFC] Generators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-62381@lists.php.net to get a copy of this message
Oh, yes... On 2012-08-22 04:35, Lester Caine wrote:
and doesn't seem to provide any outstanding advantages?
As I wrote in an earlier post: On 2012-08-09 15:30, Morgan L. Owens wrote:
I for one am lazy, and would much prefer writing: <?php function append_iterator($first, $second) { foreach($first as $i) {
       yield $i;
} foreach($second as $i) {
       yield $i;
} } ?> to <?php 87 lines elided ?>
I'm not making any assumption about where the generator returned by append_iterator() is going to be used. In particular, it might not be in a public object method or other callable. But its use would probably look something like: <?php foreach(append_iterator($left, $right) as $i) { ... do something with $i. } ?>

« previous php.internals (#62381) next »