Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!aplcen!haven!sayshell.umd.edu!louie From: louie@sayshell.umd.edu (Louis A. Mamakos) Newsgroups: comp.sys.amiga.tech Subject: Re: Fonts and freeing memory Message-ID: <1990Jan17.013417.20587@haven.umd.edu> Date: 17 Jan 90 01:34:17 GMT References: <145@ccave.UUCP> <9001161446.AA29551@en.ecn.purdue.edu> Sender: usenet@haven.umd.edu (USENET News Posting) Organization: The University of Maryland, College Park Lines: 29 In article <9001161446.AA29551@en.ecn.purdue.edu> bevis@EE.ECN.PURDUE.EDU (Jeff Bevis) writes: >>So do something like >> >> if ((WinFont = (struct TextFont *) OpenFont (&ta)) == NULL && >> (WinFont = (struct TextFont *) OpenDiskFont (&ta)) == NULL) { >> Abort ("Can't open font\n"); > >Well, I wouldn't do that either, because you can't be sure what the compiler >is going to do with your code. You've got two expressions hooked together >with a logical 'and' -- now which one will the final code try first? The one >on the right? According to my K&R, first edition in Appendix A "C Reference Manual", section 7.11: 7.11 Logical AND operator {\it logical-and-expression: expression && expression} The && operator groups left-to-right. It returns 1 if boths its operands are non-zero, 0 otherwise. Unlink &, && guarantees left-to-right evaluation; moreover the second operand is not evaluated if the first operand is 0. So the example code posted works just fine. louie