Re: [RFC] Generators

From: Date: Mon, 20 Aug 2012 14:08:04 +0000
Subject: Re: [RFC] Generators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-62286@lists.php.net to get a copy of this message
Rasmus Lerdorf: > So how about something like this: > > generator function f() { > echo "Hello World"; > } > > generator function f() { > return 1; > } > > generator function f($arg) { > if(f!$arg) yield 1; > else if($arg<0) return 1; > else return; > } > > What does the generator keyword mean in each of these cases? Anything? > Nothing? Would I see a difference either at compile-time or at execute > time if I left it out? An excellent argument to use "yield" where it is needed, instead of using "generator" at the top. Wietse

« previous php.internals (#62286) next »