On Mon, 16 Apr 2012 15:42:12 +0200, Thomas Berg wrote:
>>
>> >Premature terminations (posit/quit/admit) can almost always be handled
>> with
>> >LEAVE-type statements or immediate return from a subroutine. Some
>> languages have
>> >SIGNAL, EXIT, etc. which can help provide structured premature
>> termination for
>> >larger routines without resorting to the dreaded GOTO.
>> >
>> Rexx is a nightmare here.  The LEAVE statement, even with a specified
>> target, won't exit a (nest of) procedure(s).  The SIGNAL statement
>> trashes the DO nesting at the target level.  Shame on Rexx.
>
>I can see that as a feature.  ;)
>That prohibits some obfuscate like coding.
> 
As it stands, the only way to exit a nest of procedures is to set
a flag and RETURN, and test that flag and RETURN after each
intervening cal; hardly unobfuscated.  I'd be delighted to be
able to code, instead

    DO I =1
        DO J = 1
            DO K= 1
                CALL P1
                ...
            END K
        END J
    END I

    P1:
        CALL P2

    P2:  PROCEDURE EXPOSE J
       LEAVE J

I forgot to mention that SIGNAL trashes the DO nesting
but does not exit _any_ procedures.  I was once called on
to advise a novice colleague who had used SIGNAL, he
thought, to leave a procedure nest.  Necessarily, he had
coded all his loops with GOTO instead of DO.  It worked
fine on small data sets; he came to me for help when it
overflowed the stack on a large data set.
   
>(BTW, How do You imagine the behavior if the Signal DID NOT trash the DO 
>nesting?  I mean, of what use would that be? As You have the CALL stmt.)
> 
It could be used as a local GOTO.  But that would still be
of no use to me, because I never use SIGNAL as a GOTO,
only in SIGNAL ON NOVALUE/ERROR.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to