loops in general

Roland Rambau roland at cochise.pcs.com
Tue May 8 23:28:12 AEST 1990


al at uunet!unhd (Anthony Lapadula) writes:

->Here's an example of my typical usage, presented for dissection by the net.

Let me add more stuff for burning:

I have used 'goto's even in cases where I could easily have avoided them,
to improve the clearity of the code:

- Example 1:  a rather longish sequence of IO-operations to a graphic
              board, where the right _ordering_ is quite critical and not
              at all obvious -- and in one place I may detect that I've got
              an vacuous result and have to restart somewhat earlier in
              this sequence ( you may call it 'backtrack' )

  I decided to use 'goto' because a loop construct would have obscured
  the sequential nature of this function. ( This code is being distributed
  as a template to our customers )

- Example 2:  an ( a bit to complicated ) main loop of a little interactive
              tool, which I choose to modell after the psychological
              S-R-loop paradigma ( Stimulus-Response ). Now when starting
              this loop I had to execute a certain start-stimulus first,
              giving:

                 for( S = start ;; S = Stimulus() ) {
                   Response(S) ;
                 }

              but I found this confusing, and now use instead

                 S = start ;
                 goto Start_here ;

                 loop {

                   S = Stimulus() ;

                 Start_here:

                   Response(S) ;
                 }

It just matches my internal modell better.


Roland Rambau

  rra at cochise.pcs.com,   {unido|pyramid}!pcsbst!rra,   2:507/414.2.fidonet 



More information about the Comp.lang.c mailing list