From paul-clpython at nafpik.com Thu Aug 10 19:30:34 2006 From: paul-clpython at nafpik.com (paul cannon) Date: Thu, 10 Aug 2006 13:30:34 -0600 Subject: [clpython-devel] coroutines Message-ID: <20060810193034.GO8314@nafpik.com> This project is very interesting, and once it's working on sbcl I'd like to dig into it a bit more. Thanks for the good work. 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. It's sort of a state machine output; I don't know how it compares to the method mentioned by Ben used by c#. I could make it available if there is interest, and hopefully even complete it :) -- paul From metawilm at gmail.com Thu Aug 10 20:19:19 2006 From: metawilm at gmail.com (Willem Broekema) Date: Thu, 10 Aug 2006 22:19:19 +0200 Subject: [clpython-devel] coroutines In-Reply-To: <20060810193034.GO8314@nafpik.com> References: <20060810193034.GO8314@nafpik.com> Message-ID: Hey Paul, welcome to the list :-) On 8/10/06, paul cannon 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