----- Original Message ----- From: "George Greer" <greerga@CIRCLEMUD.ORG> > >int my_cleanup(void *var) { cleanup(var); return 0; } > > You'd need 'return 1;' I believe, but that doesn't change the yuckiness. :) 0 was correct, but it was a silly example anyway. :) > >But this same thing can be accomplished by putting the loops in a function > >and using a return to bail out instead of a goto. > > Which is the bigger abuse of the language: making a function simply due to > language deficiencies or using goto? You decide. (It would also depend on > if that loop is needed elsewhere or is a one-time thing.) I favor the goto in that particular situation unless there is another good reason to put the loops in their own function (such as reusability-- as you mentioned). Goto's are really only dangerous when they are used to change scope...such as from one function to another. I don't really subscribe to the school of thought that says don't use them, although I rarely do because there are so few situations where they are actually advantageous. I think we managed to point out a couple of them. > I have less of a problem with memory of a gloal variable used constantly > than memory of a static variable used every now and then. But we don't > have much of a choice on some functions like ctime(). I didn't mention it, but I have to say I agree that using statics to save allocation time is just plain silly. You're much better off using globals for this, as statics still have some overhead at runtime, and you have the increased memory footprint without the possibility of broad reuse. That does solve some of the other problems globals have, such as functions stepping on each others' buffers, but I would rather have local buffers than statics to solve that problem. The only reason to use statics is to hang on to values for subsequent calls to your function. As in: void update_something() { static int ticker = SOME_TIME_LIMIT; if (!(--ticker)) { /* do something */ ticker = SOME_TIME_LIMIT; } } But, I see by your other message that the horse is dead, so I'll stop beating it. Mike -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/06/01 PST