Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ncar!boulder!sunybcs!bingvaxu!leah!itsgw!batcomputer!cornell!rochester!udel!new From: new@udel.EDU (Darren New) Newsgroups: comp.lang.c Subject: Re: gotos Message-ID: <2200@louie.udel.EDU> Date: 21 Apr 88 05:19:43 GMT References: <1988Apr8.183815.3187@utzoo.uucp> <449@goofy.megatest.UUCP> <1988Apr11.201934.20594@utzoo.uucp> <748@l.cc.purdue.edu> <3470@bunker.UUCP> Sender: usenet@udel.EDU Reply-To: new@udel.EDU (Darren New) Organization: University of Delaware Lines: 40 In article <3470@bunker.UUCP> garys@bunker.UUCP (Gary M. Samuelson) writes: >In article <748@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >> >>Here is a challenge to the denigrators of goto. >> ... > >Now give me something hard. > >Gary Samuelson How about: (pseudocode) for (i = 0; i < max_in_table && key != name[i]; ++i) if (keypressed()) goto handle_key; seek(helpfile, offset[i]); if (keypressed()) goto handle_key; linecount = 0; do { read_line_from_file(); ++linecount; if (keypressed()) goto handle_key; if (read_line[0] == special_flag_char) goto handle_key; insert_spaces_and_color_codes(); if (keypressed()) goto handle_key; display_text_line(); if (keypressed()) goto handle_key; } while (linecount < 24); handle_key: c = wait_for_key_then_read_it(); switch (c) { case 'A': ... ... } I contend that if the reading and formatting and displaying are sufficiently slow, such behaviour can be desirable (i.e., on microcomputers). I would like to see a goto-less version of this that is easier to understand. - Darren New Graduate Student University of Delaware.