Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #386416
| From | Ben Bacarisse <ben@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Fixing a sample from K&R book using cake static analyser |
| Date | 2024-06-24 00:36 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87tthjnsdt.fsf@bsb.me.uk> (permalink) |
| References | <v53sl1$35qt7$1@dont-email.me> <v558hv$3dskb$1@dont-email.me> <20240623022343.ec355c69a3d9eb03ad4a50f2@gmail.moc> <878qywq7ou.fsf@bsb.me.uk> <20240624013337.36fdb40f0766c6e1c8ce67c7@gmail.moc> |
Anton Shepelev <anton.txt@gmail.moc> writes: > Ben Bacarisse to Anton Shelelev: > >> > Why are you so afraid of `goto' that you must emulate it >> > with `while' and `break'? >> >> Why are you so fond of them that you add three extra state >> variables that have to be (mentally and/or mathematically >> tracked) just understand this supposedly simply function? > > Because my attempts to fix the function without the extra > variables proved even worse. OK, but two labels and three extra state variables makes it much more complex to think about. I don't think the simple "if this then that" approach is at all problematic in this case. I can't see why adding even one goto helps when the structured approach is so simple. (I've tried to show this with code in another reply.) >> This, to me, is a textbook case of why goto is harmful. I >> have spend considerable time jumping up and down checking >> the state of all the variables and I am still not sure I >> follow what this supposedly simple function is doing. > > I have tried to keep the structure simple: all the goto's > jump down, both the labels define isolated blocks, guared by > returns, to prevent fall-though. Trying to make gotos less bad than they can be is not usually an overall positive. Whenever I see a "good" use of goto, I try to see if there's a better way with no use of goto. So far (with the exception of an example of tightly bound co-routines being simulated in a single C function) I have not yet seen one that can't. There are sometimes run-time considerations (giant state machines, for example) but even there the structured code is probably clearer. The use of gotos in those cases is not to improve the logic of the code but to placate the code generator. -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Fixing a sample from K&R book using cake static analyser Thiago Adams <thiago.adams@gmail.com> - 2024-06-21 09:45 -0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-22 01:14 +0000
Re: Fixing a sample from K&R book using cake static analyser Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-21 20:19 -0700
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-23 02:23 +0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-22 23:30 +0000
Re: Fixing a sample from K&R book using cake static analyser bart <bc@freeuk.com> - 2024-06-23 00:53 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-23 23:50 +0000
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-24 01:59 +0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 00:31 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-23 11:23 +0100
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-24 01:33 +0300
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-24 00:36 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 00:29 +0000
Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-24 04:38 +0200
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 02:56 +0000
Re: Fixing a sample from K&R book using cake static analyser Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-24 02:21 -0700
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-23 11:02 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-23 12:31 +0100
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-24 01:25 +0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-23 22:58 +0000
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-24 02:14 +0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 00:31 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-24 00:25 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 00:34 +0000
Re: Fixing a sample from K&R book using cake static analyser David Brown <david.brown@hesbynett.no> - 2024-06-24 11:39 +0200
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 23:00 +0000
Re: Fixing a sample from K&R book using cake static analyser David Brown <david.brown@hesbynett.no> - 2024-06-25 10:25 +0200
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-25 08:37 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-24 11:53 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-24 23:01 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-25 01:42 +0100
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-25 01:21 +0000
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-25 14:06 +0100
Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-25 20:35 -0700
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-26 05:18 +0000
Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 10:56 +0200
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-26 10:55 +0000
Re: Fixing a sample from K&R book using cake static analyser DFS <nospam@dfs.com> - 2024-06-26 07:20 -0400
[OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 13:20 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Michael S <already5chosen@yahoo.com> - 2024-06-26 15:54 +0300
Re: [OT] Reinheitsgebot and Beer without C Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 17:32 +0200
Re: [OT] Reinheitsgebot and Beer without C Michael S <already5chosen@yahoo.com> - 2024-06-26 20:37 +0300
Re: [OT] Reinheitsgebot and Beer without C Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 22:24 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser scott@slp53.sl.home (Scott Lurndal) - 2024-06-26 16:26 +0000
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Michael S <already5chosen@yahoo.com> - 2024-06-26 20:19 +0300
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser scott@slp53.sl.home (Scott Lurndal) - 2024-06-26 17:46 +0000
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 22:33 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-26 14:09 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-26 23:41 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-27 00:11 +0100
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-27 07:33 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-28 15:46 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-29 02:20 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser gazelle@shell.xmission.com (Kenny McCormack) - 2024-06-29 11:26 +0000
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-29 12:38 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Michael S <already5chosen@yahoo.com> - 2024-06-29 22:43 +0300
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser scott@slp53.sl.home (Scott Lurndal) - 2024-06-26 21:43 +0000
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-27 00:11 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Phil Carmody <pc+usenet@asdf.org> - 2024-06-28 13:42 +0300
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-28 14:04 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Michael S <already5chosen@yahoo.com> - 2024-06-28 17:11 +0300
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-28 19:12 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-28 11:07 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-28 20:18 +0200
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-30 02:12 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-28 15:56 -0700
Re: [OT] Re: Fixing a sample from K&R book using cake static analyser "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-28 16:00 -0700
Re: Fixing a sample from K&R book using cake static analyser David Brown <david.brown@hesbynett.no> - 2024-06-26 13:24 +0200
Re: Fixing a sample from K&R book using cake static analyser Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-27 00:20 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-26 23:45 +0000
Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-27 07:47 +0200
Re: Fixing a sample from K&R book using cake static analyser scott@slp53.sl.home (Scott Lurndal) - 2024-06-26 16:25 +0000
Re: Fixing a sample from K&R book using cake static analyser Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-24 02:55 -0700
Re: Fixing a sample from K&R book using cake static analyser Phil Carmody <pc+usenet@asdf.org> - 2024-06-25 11:47 +0300
Re: Fixing a sample from K&R book using cake static analyser Ben Bacarisse <ben@bsb.me.uk> - 2024-06-25 14:36 +0100
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-25 22:51 +0000
Re: Fixing a sample from K&R book using cake static analyser Phil Carmody <pc+usenet@asdf.org> - 2024-06-30 23:33 +0300
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-23 22:36 +0000
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@gmail.moc> - 2024-06-24 01:40 +0300
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-23 23:04 +0000
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-24 01:31 +0000
Re: Fixing a sample from K&R book using cake static analyser Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-06-24 14:28 +0300
Re: Fixing a sample from K&R book using cake static analyser Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-24 05:01 +0200
Re: Fixing a sample from K&R book using cake static analyser Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-24 09:31 +0000
Re: Fixing a sample from K&R book using cake static analyser Thiago Adams <thiago.adams@gmail.com> - 2024-06-22 17:32 -0300
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-29 00:02 +0000
Re: Fixing a sample from K&R book using cake static analyser Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-29 00:19 +0000
csiph-web