Re: Goto (Was Re: Open Source)
- Posted by Pete Lomax <petelomax at blueyonder.co.u?> Oct 26, 2007
- 775 views
Juergen Luethje wrote: > > this is my translated code (untested): Your code worked perfectly on the second test set, and gave initially correct answers on the first set, before yielding negative highvalues... I toyed with the idea of challenging you to find the bug The mistake you made is this: > Pete Lomax wrote: > > Try this then: > > function find_combination(integer jumpToDa200) > > if jumpToDa200 then goto da200 end if > > da200:: you translated this as: > }}} <eucode> > function find_combination(integer jumpToDa200) > if not jumpToDa200 then > end if > while 1 do > if not jumpToDa200 then > end if > if jumpToDa200 or flag = TRUE then <da200:: was here> > end if > end while > </eucode> {{{ The original jumped to da200 from the top of the routine, whereas you test the parameter again on every iteration around the loop. Clearing the flag at the point where the label used to be fixes it. From the number of tests it passed despite this flaw, I feel lucky to have spotted it at all. > I created code for Matt's OOEU, which does support GOTO. Then I removed > the GOTOs step by step and so in the end I had a program for the > standard Eu interpreter. Not really the answer though, installing two different interpreters, is it? Regards, Pete