Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!pcsbst! From: roland@cochise.pcs.com (Roland Rambau) Newsgroups: comp.lang.c Subject: Re: loops in general Message-ID: <1990May8.132812.8069@pcsbst.pcs.com> Date: 8 May 90 13:28:12 GMT References: <1565@amethyst.math.arizona.edu> <4700052@m.cs.uiuc.edu> <1990Apr20.192057.28204@uunet!unhd> Sender: @pcsbst.pcs.com Organization: PCS Computer Systeme GmbH Lines: 50 al@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@cochise.pcs.com, {unido|pyramid}!pcsbst!rra, 2:507/414.2.fidonet