Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!wuarchive!texbell!texsun!newstop!sun!imagen!atari!portal!portal!cup.portal.com!Tim_N_Roberts From: Tim_N_Roberts@cup.portal.com Newsgroups: comp.lang.c Subject: Re: A method for suspending functions in C Message-ID: <27614@cup.portal.com> Date: 6 Mar 90 19:26:06 GMT References: <421@charyb.COM> Organization: The Portal System (TM) Lines: 28 Someone who's name I've lost writes: > int onetoten() > { > static int state = 0; > static int i; > > switch (state) { > case 0: > for (i = 1; i <= 10; i++) { > state = 1; > return i; > case 1: > } > state = 0; > return 0; > } > } Mommy mommy, this man is scaring me. I started shaking when I read this and I'm still shaking. If I EVER find code like this in a program I'm supposed to maintain, I intend to dial 911. Can anyone convince me that this is guaranteed to work as designed? TNR@cup.portal.com | "We come in peace. Set phasers to kill." ...!sun!portal!cup.portal.com!tnr | - Star Trek Philosophy 101