1

Topic: Again about unconditional jumps

I again have a choice, whether to use unconditional jumps in the code. There is a code location in which preparation for a cycle, then a cycle, then cycle end is fulfilled at first. And in all these sections the program can define that it is time to quit a cycle and to finish performance of this code, but before it it is necessary to fulfill some actions (for example to release arrays and classes). I see three variants: 1) In places where it is revealed that it is necessary to finish procedure, there are some operators (identical). I so do often enough, and I put these operator in single line - personally it seems to me convenient. For example, so: If i> myarray.count-1 then begin myarray.free; exit; end; 2) to Use unconditional jump: If i> myarray.count-1 then goto 223;... 223: myarray.free; 3) to Create separate procedure, on output from which will be fulfilled : procedure Perform;... If i> myarray.count-1 then exit;... end;... begin perform; myarray.free; end; What variant to use more correctly?

2

Re: Again about unconditional jumps

Hello, Khimik, you wrote: K> There is a code location in which preparation for a cycle, then a cycle, then cycle end is fulfilled at first. And in all these sections the program can define that it is time to quit a cycle and to finish performance of this code, but before it it is necessary to fulfill some actions (for example to release arrays and classes). K> What variant to use more correctly? try/finally?

3

Re: Again about unconditional jumps

Hello, Jack128, you wrote: J> Hello, Khimik, you wrote: K>> There is a code location in which preparation for a cycle, then a cycle, then cycle end is fulfilled at first. And in all these sections the program can define that it is time to quit a cycle and to finish performance of this code, but before it it is necessary to fulfill some actions (for example to release arrays and classes). K>> What variant to use more correctly? J> try/finally? Then it is better repeat/until true...

4

Re: Again about unconditional jumps

Hello, Khimik, you wrote: K> Then it is better repeat/until true... Only in the event that at you the code  does not throw exceptions (that by development under windows cannot achieve).

5

Re: Again about unconditional jumps

Hello, Khimik, you wrote: K> What variant to use more correctly? As the variant 1 + RAII 2nd becomes difficult for perception and support at number magnification goto 3 + RAII or an initial variant too norms, can even is more preferable, if the code is what that logical operation and selection of procedures (simplifies code perception.