On Tue, 22 Apr 2008 18:18:14 -0500, Patrick O'Keefe wrote:

>On Tue, 22 Apr 2008 22:41:49 +0000, Ted MacNEIL
><[EMAIL PROTECTED]> wrote:
>
>>>I think abuse of ITERATE and LEAVE to be a much milder crime.
>>
>>I don't know what you mean by abuse, but when I studied
>modular/structured programming at the University of Waterloo, these
>were considered valid constructs.
>>...
>
>I absolutely agree.  Even when absolutes aren't appropriate.
>
Consider:

/* I do this all the time... */

do phonyblock = 1 for 1
    ...
    if Bailout then leave phonyblock
    ...
end phonyblock

o I put a "name = 1 for 1" on all my large blocks, and use a
  matching "end name"
  - the interpreter checks that my "end"s match my "do"s.
  - but it's a kludge because I can't name the "end" nor the
    "leave" without introducing a phony control variable.
  - but using "leave" insted of "signal" allows me to nest
    it all within a larger block.

o I always put a name on the "leave" and "iterate", even when
  they refer to then innermost block (and I have no qualms
  about multi-level "iterate" and "leave", which are possible
  if one names the control variable).
  - It's documentation.
  - It protects against unexpected results if one introduces
    another inner nesting level.

You're entitled to say that if I'm doing that, I should modularize
to smaller blocks.

I can see where someone not expecting this could consider it
"leave" abuse.

>I may have misunderstood Paul, but I assume he was describing
>such convoluted logic that use of SIGNAL might have actually
>made more understandable code.  I was trying to say the even then
>I would consider use of ITERATE and LEAVE preferable to SIGNAL.
>
Where I'd code:

    if X then do
        call B
        call C
    end;  else do
        call A
        call C
    end

My nemesis has coded:

    if X then signal B

    A:  /* unnecessary label for comparison with above.  */
        /* some stuff */
        signal C

    B:
        /* some other stuff */

    C:
        /* final stuff  */

... perhaps all within a loop that needs to be implemented with
SIGNAL because of the interior SIGNALs.

>In fact, I'm not sure that I would ever use SIGNAL to break out of a
>complex nested loop structure even if it DID greatly simplify the
>logic.   In fact, I don't even like named LEAVE; I leave each level
>seperately.  (And that is probably even more pig-headed than
>religiously avoiding SIGNAL.)
>
But you have to do that with CALLs.  There's no construct for
leaving multiply nested procedures.  Except for my nemesis's
using SIGNAL until the stack overflows.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to