Well said ..

-----Original Message-----
From: The IBM z/VM Operating System [mailto:[EMAIL PROTECTED]
Behalf Of Schuh, Richard
Sent: Monday, July 07, 2008 4:11 PM
To: IBMVM@LISTSERV.UARK.EDU
Subject: Re: REXX coding question.


There is no need to apply Boolean Algebra to a compound expression at
all. Most programmers use DeMorgan's Law, many who have never known that
they were applying a named law. There may be many, considering the
graying of the list, who do not remember that the name of the law that
they are applying is DeMorganr's Law. There is no need to use a compound
expression, either its positive or negative. There are single function
calls, such as ABBREV and WORDPOS that handle the case quite well and
are more readable. 

To be sure, there are those, I once worked with one, who think that
using NOP is one of the seven deadly sins and that stating the clause in
a positive way, as you did, is a sacrilege. :-) However, that approach
does eliminate all of the Boolean Algebra and is straight forward and
easy to follow (which makes it GOOD). If this were in a loop that is
traversed millions of times in a day, it would probably  be measurably
more efficient than calling a function. Still, the best way is whichever
way (that gives correct results) the author thinks is easier to read and
maintain.  

Don't you love the flexibility of REXX?   

Regards, 
Richard Schuh 

 

> -----Original Message-----
> From: The IBM z/VM Operating System 
> [mailto:[EMAIL PROTECTED] On Behalf Of Chip Davis
> Sent: Monday, July 07, 2008 1:27 PM
> To: IBMVM@LISTSERV.UARK.EDU
> Subject: Re: REXX coding question.
> 
> I'm afraid we're gonna have to cite you for a flagrant 
> violation of DeMorgan's Law, Howard.  ;-)
> 
> In fairness, your problem is not caused by unfamiliarity with 
> formal logic, but mere lack of clarity.  If I might suggest 
> an alternative so far overlooked:
> 
>    If \(Left(answer,1) = 'Y' | answer = 'YES') Then Do
>      Say answer
>      Say "The wrong response has been entered"
>       <etc>
> 
> This is logically equivalent and has the advantage of placing 
> the comparisons in 
> positive terms.   Also, "Left(foo,1)" is equivalent to 
> "Substr(foo,1,1)" and 
> somewhat clearer as well.
> 
> However, you are still stuck with the counter-intuitive "IF 
> NOT" condition.
> 
> So what's wrong with phrasing your question in the positive 
> and taking the other leg of the If-Then-Else?
> 
>    If Left(answer,1) = 'Y' | answer = 'YES'
>      Then Nop
>      Else Do
>        Say answer
>        Say "The wrong response has been entered"
>          <etc>
> 
> Does that not make the intent of the code much clearer?
> 
> -Chip-
> 
> On 7/7/08 16:23 Howard Rifkind said:
> > This is confusing me.
> >  
> > The response to the variable 'answer' is a Y.
> >  
> > Yet this portion of the code isn't working.  Shouldn't the 
> logic just 
> > fall thru because the response was a Y.
> >  
> > IF SUBSTR(ANSWER,1,1) /= 'Y' | ANSWER /= 'YES' THEN  
> >    DO                                                
> >      SAY ANSWER                                      
> >      SAY 'THE WRONG RESPONSE HAS BEEN ENTERED'       
> >      SAY                                             
> >      SAY 'PROCEDURE IS TERMINATING, PLEASE TRY AGAIN'
> >      EXIT                                            
> >    END                                               
> >  
> > Thanks
> 

Reply via email to