On Mon, Dec 22, 2008 at 3:17 AM, Edward Z. Yang wrote: > > Hello all, > > While I'm all for using appropriate language features to make > implementations more readable and efficient, the use of the "yield" > keyword in the tokenizer makes me pause a little. Why should we not use > yield? [...] > Of course, you can treat these as the complaints of a fogey on PHP who > doesn't get access to such a nice, shiny language feature. I'd be > interested in what you all have to say, though.
Can't you replace the use of "yield" with a (non-rewindable) PHP Iterator? Python: def my_range(first, count, step): while count > 0: yield first first += step count -= 1 for i in my_range(1, 10, 2): print i PHP: class MyRange implements Iterator { private $cur; private $left; private $step; public MyRange($first, $count, $step) { $this->cur = $first; $this->left = $count; $this->step = $step; } public function rewind() { } public function next() { $this->cur += $this->step; $this->left -= 1; } public function current() { return $this->cur; } public function valid() { return $this->left > 0; } public function key() { return "I'm no PHP expert"; } } foreach (new MyRange(1, 10, 2) as $i) { echo $i . "\n"; } ...and I'm +1 to what James said (don't change impls just because PHP does not have "yield". -- Thomas Broyer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "html5lib-discuss" group. To post to this group, send email to html5lib-discuss@googlegroups.com To unsubscribe from this group, send email to html5lib-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/html5lib-discuss?hl=en-GB -~----------~----~----~----~------~----~------~--~---
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4