Re: [RFC] Generators
| From: | Andrew Faulds | Date: | Mon, 20 Aug 2012 20:19:02 +0000 |
| Subject: | Re: [RFC] Generators | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62310@lists.php.net to get a copy of this message | ||
On 18/08/12 13:21, Derick Rethans wrote:
On Sat, 11 Aug 2012, Nikita Popov wrote:You know, this conversation feels like it's going in circles. I thought we already agreed there wouldn't be one.Hi internals! I think there already was a lot of discussion on the generators, so it's time to move to the next step. I'd like to vote on the feature in two weeks, so this the "announce[ment] on internals@, by the author, with the intention of voting on it".I've some comments how that I've read the RFC:https://wiki.php.net/rfc/generatorsIf you have any further feedback, now would be a good time to raise it. If there is something you previously posted, but which I didn't yet address, please let me know. There were around 150 mails and I sure missed some of them.Recognition of generator functions 1. Any function which contains a yield statement is automatically a generator function. 2. The initial implementation required that generator functions are marked with an asterix modifier (function*). This method has the advantage that generators are more explicit and also allows for yield-less coroutines. The automatic detection was chosen over the asterix modifier for the following reasons:I am against this. This is even more magic in PHP. Is it really that difficult to have to mark the function with a different keyword, such as "generator":
-- Andrew Faulds http://ajf.me/generator function getLinesFromFile($fileName) {This should not be a concern, sure, it's annoying for the hiphop developers but they chose to copy and then *chance* the PHP language for their own effect.if (!$fileHandle = fopen($fileName, 'r')) { return; } There is an existing generator implementation in HipHop PHP, whichuses automatic-detection. Using the asterix modifier would break compatibility.yield: Yields the value null with an auto-incrementing integer key.What is the usecase for this? cheers, Derick