Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Minimum amount of syntax for C language |
| Date | 2016-11-17 11:56 -0800 |
| Organization | None to speak of |
| Message-ID | <ln7f81hodo.fsf@kst-u.example.com> (permalink) |
| References | (5 earlier) <ec02f6d7-55e4-421f-9873-9e1128b534a9@googlegroups.com> <o0a2o7$j0o$3@dont-email.me> <e93fdmFn7n5U1@mid.individual.net> <6963fc34-48b1-490f-b404-7ff4975b7780@googlegroups.com> <8d7b4901-003a-47d7-ab25-15d661da9f63@googlegroups.com> |
Thiago Adams <thiago.adams@gmail.com> writes:
> On Thursday, November 17, 2016 at 3:03:40 PM UTC-2, John Bode wrote:
[...]
>> Not *required*, but one place where it is useful (and not immediately a
>> sign of poor design or practice) is bailing out of a deeply nested loop
>> or multi-step resource allocation process:
>>
>> for ( ... )
>> for ( ... )
>> for ( ... )
>> if ( some_error )
>> goto exit:
>>
>> exit: // clean up
>>
>> Obviously, you'll want to structure your code such that you avoid that
>> situation, but sometimes it simply isn't possible (or, the level of
>> effort required to do so is not worth the tradeoff).
>
> The other option to exit is add an external do {} while(0) and break.
>
> do
> {
> if ()
> {
> if ()
> {
> if ()
> {
> break; //ok
> }
> }
> }
> } while(0);
That's not helpful if you need to bail out of multiple nested loops.
[...]
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Minimum amount of syntax for C language "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:56 +0800
Re: Minimum amount of syntax for C language BartC <bc@freeuk.com> - 2016-11-13 11:26 +0000
[OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 19:41 +0800
Re: [OT] BartC <bc@freeuk.com> - 2016-11-13 12:42 +0000
Minimum amount of syntax for C language "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 20:45 +0800
Re: Minimum amount of syntax for C language jameskuyper@verizon.net - 2016-11-13 07:42 -0800
Re: Minimum amount of syntax for C language "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-14 00:01 +0800
Re: Minimum amount of syntax for C language jameskuyper@verizon.net - 2016-11-13 10:00 -0800
Re: Minimum amount of syntax for C language "Osmium" <r124c4u102@comcast.net> - 2016-11-13 13:16 -0600
Re: Minimum amount of syntax for C language BartC <bc@freeuk.com> - 2016-11-13 19:28 +0000
Re: Minimum amount of syntax for C language Thiago Adams <thiago.adams@gmail.com> - 2016-11-14 08:10 -0800
Re: Minimum amount of syntax for C language John Bode <jfbode1029@gmail.com> - 2016-11-14 12:34 -0800
Re: Minimum amount of syntax for C language "Osmium" <r124c4u102@comcast.net> - 2016-11-16 10:22 -0600
Re: Minimum amount of syntax for C language supercat@casperkitty.com - 2016-11-16 08:33 -0800
Re: Minimum amount of syntax for C language "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-17 22:11 +0800
Re: Minimum amount of syntax for C language BartC <bc@freeuk.com> - 2016-11-17 16:30 +0000
Re: Minimum amount of syntax for C language "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-18 01:05 +0800
Re: Minimum amount of syntax for C language John Bode <jfbode1029@gmail.com> - 2016-11-17 09:03 -0800
Re: Minimum amount of syntax for C language Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-17 13:58 -0500
Re: Minimum amount of syntax for C language BartC <bc@freeuk.com> - 2016-11-17 19:10 +0000
Re: Minimum amount of syntax for C language Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-17 17:41 -0500
Re: Minimum amount of syntax for C language Thiago Adams <thiago.adams@gmail.com> - 2016-11-17 11:03 -0800
Re: Minimum amount of syntax for C language Keith Thompson <kst-u@mib.org> - 2016-11-17 11:56 -0800
Re: Minimum amount of syntax for C language "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 12:17 -0800
Re: Minimum amount of syntax for C language Thiago Adams <thiago.adams@gmail.com> - 2016-11-17 12:21 -0800
csiph-web