"TP" == Tim Peters <tim.one@home.com> writes:
I'm not sure about Jython. The sys._getframe(), frame.suspend(), and frame.resume() low level interface is nice. I think Jython must know which frames are going to be suspended at compile time.
TP> Yes, Samuele said as much. My belief is that generators don't TP> become *truly* pleasant unless "yield" ("suspend"; whatever) is TP> made a new statement type. Then Jython knows exactly where TP> yields can occur. As in CLU (but not Icon), it would also be TP> fine by me if routines *used* as generators also needed to be TP> explicitly marked as such (this is a non-issue in Icon because TP> *every* Icon expression "is a generator" -- there is no other TP> kind of procedure there). If "yield" is a keyword, then any function that uses yield is a generator. With this policy, it's straightforward to determine which functions are generators at compile time. It's also Pythonic: Assignment to a name denotes local scope; use of yield denotes generator. Jeremy