On 5/08/2017 7:19 AM, Smith III, Phil (HPE Data Security (Voltage)) wrote:
Paul Gilmartin wrote:
Rexx has no GOTO.  "break" is LEAVE [control-variable] (and "continue is
ITERATE [control-variable]).  I never use Rexx SIGNAL other than to force
an error; its side effects are dreadful.
By "to force an error", do you mean "to say that something bad happened and end the program"? 
Because if so, I agree 100% (well, except for the slightly perverse "calculated goto" via "SIGNAL 
VALUE", which is useful in *very* specific, rare, heavily documented instances).

That is, I find this code much easier to read and maintain:

do <someloopcondition>
    ...
    if <statetest1 fails> signal BadCase1
    ...
    if <statetest2 fails> signal BadCase2
    ...
end
...
* And way down below somewhere:
BadCase1:
say "The very bad case#1 happened!"
exit 1

BadCase2:
say "The very bad case#2 happened!"
exit 2
(etc.)


That looks perfectly reasonable to me.


I don't want to get into a theological argument on a Friday afternoon, but having grown 
up with PL/I, the "No GOTOs noway never nohow" has always seemed overly rigid. 
Plus I'm currently living with code that uses the second technique above, and it's hell 
to debug (ok, in this case, it's much worse because it tends to set the maybeError *once* 
and then test five things, so you have to try to figure out which of the five really 
caused the error...just lazy programming).

The "goto is evil" debate is phony. A well placed goto can eliminate duplicate code. I never use gotos these days purely because I program in languages that have exceptions and finalization. In less sophisticated languages error handling and object finalization is much simpler using gotos. I've worked on projects that had coding standards prohibiting the use of goto and the code quality was inferior.

...phsiii

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to