On Fri, 18 Jun 2021, at 16:57, Bob Bridges wrote:
> Ack!  To my mind
> 
>   if fx then
>     do
>       ntim=ntim+1
>     end
>   else
>     do
>       nres=nres+1
>     end
> 
> ...is much harder to read than
> 
>   if fx then ntim=ntim+1
>         else nres=nres+1

Yes, I agree.  But a more compact style like 

if fx then do
   ntim=ntim+1
end
else do
   nres=nres+1
end

is less of an eyesore, and if one is using a text editor that matches
if then do/end/else/end the extra space used is a small compromise
for getting the visual coloured confirmation that the structure is right,

I do use the simple form, but usually only when the actions are 
very similar eg 

if number = 1 then thingmsg = "The thing is"
                     else thingmsg = "The things are"

say thingmsg "working perfectly."


I'm generally not happy to mix the forms as eg 

if simple then say "something simple"
else do
    ...
   . ...
    say "phew! that was complex!"
end


Also in my experience it's often necessary to add extra lines of code
(eg for debugging) on one or other arm of a test and it's a lot easier
later to add code within the do/ends of

if fx then do
   ntim=ntim+1
end
else do
   nres=nres+1
end

than to have to add all the do/end stuff as well as the debugging
code later on.  It's also easier, if need be, to comment the if and 
else parts of that if you've got unlimited space in the two arms of
the structure.

-- 
Jeremy Nicoll - my opinions are my own.

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

Reply via email to