Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
True or False
Message
From
16/01/2007 12:06:23
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185857
Message ID:
01185943
Views:
11
>>>>>We now know we were wrong and why. But does anybody here (except Sergey, who obviously appears to know why) know why?
>>>>
>>>>The precedence of AND means that AND is evaluated first (like multiplication) and then the OR (like addition). So your expressions basically read as
>>>>
>>>>
? .f. or .t. or (.f. and .f.) or .f.
>>>>? .f. or .f. or (.t. and .f.) or .f.
>>>>
>>>>The precedence of conjunction over disjunction makes parentheses unnecessary, hence they need not be written. It always behaves as if they are.
>>>
>>>Yes, you are right. Nevertheless, my suggestion to other developers is to use the parentheses anyway. I always use the (formally unnecessary) parentheses anyway and today I was confronted with a piece of source code without the parentheses. It initially really puzzled me.
>>
>>You're not the only one - I've seen here on UT logical expressions where parentheses were added for clarity. Let's face it, a logical expression with five terms or more is not exactly a roadsign to be understood in a millisecond. And for many people it's a bit over their head.
>>
>>I once had a case of a logical expression which extended over eight lines (in Cobol :). It took me good ten minutes to reduce it to an equivalent two-liner. The person who wrote that was an economist. That taught me that while I have the feeling the logical expression are easy to do, I may not share that feeling with all the people :).
>
>The same is true for the expressions after WHERE, FOR, CASE and so on. It is my habit to present all combined ´parts´ of the expression not only between parentheses, but also on separate lines. Example:
>
select ;
>   * ;
>   from sometable ;
>   where nose > 4_inch ;
>   or    mouth > 3_inch ;
>   or    ( ears > 5_inch and hair > 30_inch ) ;
>   or    hand > 10_inch ;
>   into cursor c_table
You've got to be kidding
Previous
Reply
Map
View

Click here to load this message in the networking platform