RE: [PHP-DEV] Re: Generators in PHP

From: Date: Thu, 09 Aug 2012 10:11:37 +0000
Subject: RE: [PHP-DEV] Re: Generators in PHP
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  Groups: php.internals 
Request: Send a blank email to internals+get-62100@lists.php.net to get a copy of this message
> -----Original Message----- > From: Andrew Faulds [mailto:ajf@ajf.me] > Sent: 25 July 2012 18:03 [...] > Fact: Adding a new name for a special kind of function as a syntax > construct is going to cost (possibly unnecessary) time and energy, > because now you have functions, and weird things that look almost > like > functions but aren't and can only be used to make generators. That looks to me like a perfect argument *in favour* of the "generator" keyword! I'm a very literal kind of person, and I would absolutely want "weird things that look almost like functions but [...] can only be used to make generators" to be clearly labelled as such without having to hunt through the body of the not-quite- function. 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. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS,  LS1 3HE,  United Kingdom E: m.ford@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

« previous php.internals (#62100) next »