Re: goto: it's conceded

new topic     » goto parent     » topic index » view thread      » older message » newer message

ken mortenson wrote:
> 
> Derek Parnell wrote:
>  
> > David Cuny wrote:
> > > Well, sometimes you're nested deep, and you need to get out. Implementing
> > > it
> > > 
> > > without GOTO is messy and error prone. With GOTO, it's clear
> > > what's happening and it executes as expected.
> 
> Sorry to contradict you but your example demostrates perfectly (with some
> elaboration) exactly why GOTO result in less clear code.  Thank you for
> providing an example that allows me to make this point...
>  
> > We can now do this (in V4.0) ...
> > 
> >    while cond1 label "toplevel" do
> >       . . .
> >       while cond2 do
> >        . . .
> >          while cond3 label "anotherpoint" do
> >            . . .
> >             while cond4 do
> >               . . .
> >               if abc then
> >                   exit "toplevel"
> >               else
> >                   continue "anotherpoint"
> >               end if
> >             end while
> >         end while
> >      end while
> >    end while
> 
> Any person that wrote this probably expects...
> 
> while cond4 do
> 
> ...to be the beginning of a loop.  Does everybody see that?  The fact
> is, it's not.  Here's how I would rewrite the code (without labels) to
> make it's functionality much clearer.
> 
> procedure example()   
>   while cond1 do
>     ...
>     while cond2 do
>       ...
>       while cond3 do
>         ...
>         if cond4 then
>           ...
>         end if
>         if abc then return end if
>       end while
>     end while
>   end while
> end procedure

 My mistake, the procedure should actually be withing the first loop.  I hit
tab and something else and this got posted before I had a chance to 
 proof it.  but I think my point is still relevant.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu