For Programmers: Free Programming Magazines  


Home > Archive > Cobol > July 2005 > Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap
Joe Zitzelberger

2005-07-25, 10:02 pm

In article <n_PCe.121287$HI.53338@edtnps84>,
"Oliver Wong" <owong@castortech.com> wrote:
> The adding of switches is mainly because this is pretty much the
> technique used by all GOTO-eliminating algorithms I've seen discussed in the
> literature and papers I've read on this topic. If there's a way to perform
> GOTO removal without adding new switches, I'd very much like to know about
> it because generating meaningful names for switches is rather difficult
> (these names WILL probably eventually be seen by some human, at least in the
> form of the outline of the program generated at the end, if not directly in
> the COBOL source code itself).
>
> Whether or not there will be a "switch eliminating phase" is yet to be
> seen; it's much too early at this point to tell whether it will be
> nescessary, feasible, or even desirable. Right now, when confronted with
> "lots of switches" versus "lots of GOTOs", my requirements state that "lots
> of switches" is the lesser of two evils.
>
> - Oliver


In many (not all) cases, you can use knowledge of idiomatic Cobol to
remove the need for switches. Consider the common "go to exit":

1234-Some-Para.

... some code ...

If condition
go to 1234-some-para-exit.

... lots of code ...

1234-Some-Para-Exit.
exit.

This can always be rewritten as:

1234-Some-Para.

... some code ...

If NOT (condition)
... lots of code ...
END-IF

1234-Some-Para-Exit.
exit.

I have a hunch that you can do this without switches EXCEPT for the case
where a go to jumps over a paragraph boundary (E.G in a long perform
thru).
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com