[clpython-devel] coroutines
Willem Broekema
metawilm at gmail.com
Thu Aug 10 20:19:19 UTC 2006
Hey Paul, welcome to the list :-)
On 8/10/06, paul cannon <paul-clpython at nafpik.com> wrote:
> I saw some mention of coroutines in the list archive. I spent some time
> working on implementing some python-ness in lisp, and have a partially
> complete code transformer that can make generators and coroutines
> possible.
I'm certainly curious about your work. CLPython fully supports
Python's generators except for the fairly new 'yield as expression'
feature ("x = yield y"). By tracing function
'rewrite-generator-funcdef-suite you can see how a generator is
rewritten into a state machine.
Rewriting of generator's function bodies into the state machine made
me feel an assembly programmer: tagbody, goto... :-) Most of the
rewrite rules were straightforward, but handling 'yield inside
'try/except correctly required some care.
As for getting it running on SBCL: probably the heavy use of custom
declarations of the form "(declare (pydecl ...))" and environment
inspection functions, are the hardest issues in making CLPython
portable; but I have to admit I looked only briefly at what other
implementations offered in this aspect.
- Willem
More information about the Clpython-devel
mailing list