After reading <a href="http://blog.plt-scheme.org/2007/07/control-resumed.html">http://blog.plt-scheme.org/2007/07/control-resumed.html</a> I decided to look into prompt/control/%/fcontrol and the rest of the goodies in control.ss
<br><br>So based on the example from the blog post I did this python like snippet.<br><br>================<br>(require (lib "control.ss"))<br><br>(define (make-step)<br> (define (body)<br> (yield 1)<br> (yield 2)
<br> (yield 3)<br> 'finished)<br> (define (yield value) (control resume-here (set! _body_ resume-here) value))<br> (define (generator) (prompt (body)))<br> (generator))<br>================<br><br>I decided to look into turning it into a macro, such that the following ends up being correct code
<br>==============<br>(define/y (step) <br> (yield 1)<br> (yield 2)<br> (yield 3)<br> 'finished)<br>==============<br><br>My problem is that I don't know how to define yield as a macro inside the define/y scope, since it need to be able to access _body_, which is a defined in define/y. All I come up with are various non-hygienic (and simply broken) variations.
<br><br>Can you point me to some examples doing something similar (and/or relevant docs).<br><br>I know that there is generator.ss in planet, but for me this is a nice exercise, since I'm trying to build some intuition about scheme macros. I was avoiding them for too long...