Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #8750

Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0);

From "io_x" <a@b.c.invalid>
Newsgroups comp.lang.c
References (5 earlier) <slrnj2qbqb.2ral.willem@toad.stack.nl> <lnoc0iibqf.fsf@nuthaus.mib.org> <f407c749-1960-4238-acb0-89998e9c4a8e@q15g2000yqk.googlegroups.com> <4e2e855f$0$44206$4fafbaef@reader1.news.tin.it> <1baa3f01-091a-4fff-8242-2b2b7ee0d0d4@f20g2000yqm.googlegroups.com>
Subject Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0);
Date 2011-07-26 19:21 +0200
Message-ID <4e2ef70a$0$15666$4fafbaef@reader2.news.tin.it> (permalink)
Organization TIN.IT (http://www.tin.it)

Show all headers | View raw


"Nick Keighley" <nick_keighley_nospam@hotmail.com> ha scritto nel messaggio
news:1baa3f01-091a-4fff-8242-2b2b7ee0d0d4@f20g2000yqm.googlegroups.com...
On Jul 26, 10:16 am, "io_x" <a...@b.c.invalid> wrote:
> "Nick Keighley" <nick_keighley_nos...@hotmail.com> ha scritto nel messaggio


> For instance this is reasonably clear:-
>
> loop:
> if (!finished)
> {
> do_more_stuff();
> goto loop;
> }
>
> This less so
>
> loop1:
> if (!finished)
> {
> do_first_stuff();
> if (reloop())
> goto loop1;
> loop2:
> do_second_stuff();
> if (sudden_death())
> goto end;
> do_third_stuff()
> goto loop1;
> }
>
> end:
> skip_many_pages();
> if (reprocess_event())
> goto loop2;
>
> #i not have all your fears
> #this "goto loop2;" seem to me a problem [i never wrote something as that]

trust me I've seen stuff like this. If you restrict your gotos to
structures isomorphic to structured programs then they aren't too hard
to analyse. But they *do* need to be analysed and this is why a goto-
ful program is harder than a goto-less program (everything else being
equal!)

#are you saing that *not* goto programming has not need to be analysed
#where is the difference? with goto it is possible one know better
#of while() etc when and if code is execute

> #i there will write
>
> # {renewVaribleLoop1and2(); goto loop1}
> #or but with some problem
> # {renewVaribleLoop1and2(); goto loop2}
>
> #and write a end condition that exit function
> #or program

I don't know how you can be sure the two programs are equivalent.
Which is my point.

#i don't know if they are equivalent because functions has to be defined

> #but i woudl write it in this way
> ----------
> loop1:
> if(finished) goto end;
> do_first_stuff();
> if (reloop()) goto loop1;
> loop2:
> do_second_stuff();
> if(sudden_death()) goto end;
> do_third_stuff() goto loop1;
> end:
> ...
> finished=0;
> ...
> goto loop1;
> or
> {inizilizesudden_death(); goto loop2}
> ---------

I refer the honourable memeber to my response to his previous
question.

#what question? who is the "honourable memeber"?

> The full horror is jumping into a loop.
>
> #yes, if one excluse the case the loop start in the middle as
> # i=0; goto .b;
> # .a: printf("%d\n", i);
> # ++i;
> # .b: if(i<=someVar) goto .a;
>
> A simple loop can be recoded
> as a for or while. the second example needs a lot more analysis. The
> above is much *more* structured than the typical code-de-jour. There
> could be a dozen pages between the top and bottom of (maybe) a loop.
> And those dozen pages whould be nested ten deep (unless the coder
> thought indentation was for wimps).
>
> When gotos are discussed people don't always realise the full horror
> of old code.
>
> #olds not used indentation and multi instruction for line with goto
> #for reduce size of function and see all function
> #with the right indentation...

trust twelve page functions don't squish down onto one page no matter
how many statements you put on a line. The great advantage of gotos is
taht you dispense with the indentation. Hence enabling you to compress
the code even more.

#20 page of function for me are very rare
#99% function are long < my screen

loop1: if (!finished) goto end
do_first_stuff();
if (reloop())goto loop1;
loop2: do_second_stuff();
if (sudden_death()) goto end;
do_third_stuff()
goto loop1;
end: skip_many_pages();
if (reprocess_event()) goto loop2;

################################
loop1: if(finished) goto end;
       do_first_stuff();
       if (reloop())goto loop1;

loop2: do_second_stuff();
       if(sudden_death()) goto end;
       do_third_stuff()
       goto loop1;

end:   skip_many_pages();
       if(reprocess_event()) goto loop2;
/*
 this mean nothing;
 i would argue that first of "goto loop2" event just above:
 "finished" has to be set to "0"
 reloop() has to be reinezializated as the start of loop1
 sudden_death() has to be reinezializated as the start of loop1
 but it is only how i image can be
 because if is not so, i would rewrite the loop2 so

loop1: if(finished) goto here;
       do_first_stuff();
       if (reloop())goto loop1;
loop2: do_second_stuff();
       if(sudden_death()) goto here;
       do_third_stuff()
       goto loop1;

Loop2: do_second_stuff();
       if(sudden_death()) goto end;
       do_third_stuff()
here:  skip_many_pages();
       if(reprocess_event()) goto Loop2;
end:

*/
#################################


Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-22 08:49 +0200
  Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-22 00:58 -0700
  Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); gwowen <gwowen@gmail.com> - 2011-07-22 01:46 -0700
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); gazelle@shell.xmission.com (Kenny McCormack) - 2011-07-22 13:16 +0000
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-22 06:35 -0700
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); tom st denis <tom@iahu.ca> - 2011-07-22 08:37 -0700
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-22 12:20 -0400
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-22 16:41 +0200
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-22 12:10 -0400
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-22 19:39 +0100
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); luser- -droog <mijoryx@yahoo.com> - 2011-07-22 21:05 -0700
        Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-23 13:24 +0100
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); gazelle@shell.xmission.com (Kenny McCormack) - 2011-07-23 15:11 +0000
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "io_x" <a@b.c.invalid> - 2011-07-23 22:16 +0200
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-22 09:39 -0700
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-22 22:30 +0300
        Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-22 13:15 -0700
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-23 01:02 +0300
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Jens Schweikhardt <usenet@schweikhardt.net> - 2011-07-23 13:06 +0000
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-23 16:51 +0300
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-25 12:06 -0400
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Jens Schweikhardt <usenet@schweikhardt.net> - 2011-07-25 20:39 +0000
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-26 10:43 -0400
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-26 08:58 -0700
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-25 12:03 -0400
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-29 01:51 +0300
  Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); August Karlstrom <fusionfile@gmail.com> - 2011-07-22 12:15 +0200
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-22 16:11 +0200
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-22 08:14 -0700
        Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Thomas Boell <tboell@domain.invalid> - 2011-07-29 14:38 +0200
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); James Kuyper <jameskuyper@verizon.net> - 2011-07-29 09:23 -0400
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Thomas Boell <tboell@domain.invalid> - 2011-07-29 15:58 +0200
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); James Kuyper <jameskuyper@verizon.net> - 2011-07-29 10:42 -0400
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Willem <willem@toad.stack.nl> - 2011-07-29 14:56 +0000
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); James Kuyper <jameskuyper@verizon.net> - 2011-07-29 20:47 -0400
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Willem <willem@toad.stack.nl> - 2011-07-30 09:12 +0000
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); James Kuyper <jameskuyper@verizon.net> - 2011-07-30 07:30 -0400
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Thomas Boell <tboell@domain.invalid> - 2011-07-29 17:08 +0200
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Ali <abdulrazaq@gmail.com> - 2011-07-29 08:21 -0700
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-22 12:24 -0400
        Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-25 10:34 +0200
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Willem <willem@toad.stack.nl> - 2011-07-25 08:54 +0000
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-25 09:08 -0700
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Willem <willem@toad.stack.nl> - 2011-07-25 16:52 +0000
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-25 11:37 -0700
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); cri@tiac.net (Richard Harter) - 2011-07-25 20:16 +0000
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-26 10:23 +0200
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 00:49 -0700
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "io_x" <a@b.c.invalid> - 2011-07-26 11:16 +0200
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 03:09 -0700
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "io_x" <a@b.c.invalid> - 2011-07-26 19:21 +0200
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-27 00:43 -0700
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); "io_x" <a@b.c.invalid> - 2011-07-27 11:29 +0200
                Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-27 08:30 -0700
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Kenneth Brody <kenbrody@spamcop.net> - 2011-07-26 10:39 -0400
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Hallvard B Furuseth <h.b.furuseth@usit.uio.no> - 2011-07-26 12:37 +0200
        Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Francois Grieu <fgrieu@gmail.com> - 2011-07-26 12:52 +0200
          Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Hallvard B Furuseth <h.b.furuseth@usit.uio.no> - 2011-07-26 13:18 +0200
            Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Keith Thompson <kst-u@mib.org> - 2011-07-26 08:57 -0700
              Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Hallvard B Furuseth <h.b.furuseth@usit.uio.no> - 2011-07-27 10:18 +0200
  Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Ali <abdulrazaq@gmail.com> - 2011-07-23 15:38 -0700
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Ali <abdulrazaq@gmail.com> - 2011-07-24 09:25 -0700
      Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-07-26 01:01 -0700
    Re: do{switch(0)default:{/*break or continue*/;}/*cleanup*/}while(0); gwowen <gwowen@gmail.com> - 2011-07-25 03:08 -0700

csiph-web