En Mon, 05 May 2008 00:09:02 -0300, hdante <[EMAIL PROTECTED]> escribió:
> Isn't this guy a bot ? :-) It's learning fast. I believe there is a > "frame" in C, composed of its stack and globals. For generators in C, > you may look for "coroutines". For example, see: > > http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html > > A sample code follows: > > #define crBegin static int state=0; switch(state) { case 0: > #define crReturn(i,x) do { state=i; return x; case i:; } while (0) > #define crFinish } > int function(void) { > static int i; > crBegin; > for (i = 0; i < 10; i++) > crReturn(1, i); > crFinish; > } > > The "suspended state" is saved in the static variable. It's not > necessary to save the complete "frame", only the suspended state. Quoting the author himself, "this is the worst piece of C hackery ever seen" -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list