3 ms·
This isn't really PHP's fault. These generators and the generators that are creeping into Javascript are based on Python's, which have the same issue you menti
by anonymoushn 14y ago
This isn't really PHP's fault. These generators and the generators that are creeping into Javascript are based on Python's, which have the same issue you mention:
>>> def other_cool_function():
... print "Hello, world!\n"
... yield 7
...
>>> other_cool_function()
<generator object other_cool_function at 0x10081b140>
Of course, I would prefer to have coroutines or call/cc, but generally these get shot down as terrible ideas by the people who are actually in charge of making decisions. In Python you can get around this using greenlet. I'm told HipHop has these goodies as well. No dice if you need to write Javacript or non-Facebook PHP, though.