Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!spdcc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: ambiguous ? Message-ID: <733@lakart.UUCP> Date: 27 Oct 89 16:43:36 GMT References: <1989Oct25.090802.19444@gdt.bath.ac.uk> Organization: Lakart Corporation, Newton, MA Lines: 23 exspes@gdr.bath.ac.uk (P E Smee) sez: > ..... Algol may have this right, > they offer two sets of logical operators: AND and OR which do not short > circuit; and ANDTHEN and ORELSE which do. This gives the programmer total > control, and might be worth considering for some future version of C or > a C offspring. Both are useful, and making either from the other in a > language which only supports one is fiddly at best. However, those of us that know De Morgan's laws can get by very neatly with ! & | and a couple of preprocessor macros for non-short circuiting operators. #define and(x, y) (!((!(x)) | (!(y)))) #define or(x, y) (!((!(x)) & (!(y)))) This does rather assume that your optimizer is up to the job, but then that's a whole other thread. Also, as someone once said "Never sacrifice clarity for efficiency" (gets +6 ring of fire resistance ready :-) ) -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+