× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

Seriously, how is "If not something();" different from "If something() =
false;" or "If something() = '0';?" They all mean the same thing: not =
'0' = false. To me, it's a matter of preference. Since my logic spans
several languages, "if not" is common and not difficult to read. I
would rather have recognizable commonalities between code variances than
gear myself up for avoidable nuances.

Yeah, I agree with Tom with regards to the examples that have been posted here so far. In those examples, anyone should be able to figure it out quite easily.

However, at the same time, I also agree that negative logic makes things a little trickier to understand. Did it make any difference to the examples posted here so far? No. They were too simple! But, there is a point at which program logic starts to get too convoluted and hard to read. And negative logic can sometimes be the "last straw" in making something convoluted.

Consider this example:

chain ItemNo ItemMaster;
if not %found;
NotValid = *on;
endif;

. . . 100 lines of code . . .

If (not NotValid);
// use item
endif;

This, to me, is getting convoluted. The negatives in the "not notvalid" make things complex... but that's still a relatively simple example. Even so, it's nicer to have something like this:

chain ItemNo ItemMaster;
if not %found;
Valid = *on;
endif;

. . . 100 lines of code . . .

if Valid;
// use item
endif;

The more positives in your logic, the easier it is to understand. There are certainly cases where negative logic is easy and not a problem.. but it should be tempered with judgement. If it looks too complex, the logic should be cleaned up a bit.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.