OR'd conditions.....
Posted in 1993
Topics: General Discussion
Fellow Netters...... I ran into a "problem" that I found somewhat disturbing and wanted to alert others to this..... If you have OR'd conditions in an "IF" statement, ***ALL*** conditions are checked regardless of the status of the 1st condition. In "C" (and most other languages that I know), if the 1st condition is TRUE, then the remaining conditions are skipped since the entire statement MUST logical to TRUE. EXAMPLE: DEFINE add_mode SMALLINT MAIN LET add_mode = TRUE IF add_mode OR upd_ok() THEN <do stuff....> END IF FUNCTION upd_ok() <do stuff.....> RETURN (either TRUE or FALSE) END FUNCTION In the above example, upd_ok() is ALWAYS called. Now, I reviewed the .ec file created during compile and I can see WHY it is always called. What I don't understand is why Informix implemented it this way?? There can be significant overhead in calling a function even if its results aren't needed (or in my case even desired). Has anyone ever run into this before or had trouble with this??? Thanks guys and gals. -- Mark E. Heringslake CompuData Inc. - Philadelphia, PA Help, I'm in a loop and I can't get Phone: (215) 824-3000 Help, I'm in a loop and I can't get FAX: (215) 824-4423 Help, I'm in a loop and I can't get Help, I'm in a loop and I can't get UUCP: ..!uunet!cdin-1!mark INTERNET: mark@compu.com