Very creative, but I still recommend clearer solutions, unless the code will never be maintained... Certainly you can solve the original demand planning better code structure. What about Kari post the problem? WagnerT > > to avoid the recursion problem while maintaining type safety, try > this (code > tested with Borland C++ 5.01): > > // declare a struct, but don't say what is in it yet > > struct x; > > // declare STATEFUNCPTR to be a pointer to a func returning an 'x' > > typedef struct x (*STATEFUNCPTR)(void); > > // Now explain what is in an 'x' > typedef struct x { > STATEFUNCPTR ptr; > } x; > > // predeclare your state functions > > x func_a(void); > x func_b(void); > > // one way of selecting the next function to run > x func_a(void) > { > static x goto_a = {func_a}; > static x goto_b = {func_b}; > > if (1==1) > return goto_a; > else > return goto_b; > } > > // another way of doing it > x func_b(void) > { > x result; > > if (1==1) > result.ptr = func_a; > else > result.ptr = func_b; > > return result; > } > > // Now the 'main' routine > > void test(void) > { > x foo_ptr = {func_a}; > for (;;) > foo_ptr = (*foo_ptr.ptr)(); > } > > > > Bob Ammerman > RAm Systems > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.384 / Virus Database: 216 - Release Date: 21/08/02 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.384 / Virus Database: 216 - Release Date: 21/08/02 -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body