From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f8a1,e7e13c943c611b62 X-Google-Attributes: gid10f8a1,public X-Google-Thread: 102b75,be3d6a6131c61fa7 X-Google-Attributes: gid102b75,public X-Google-Thread: 1164f8,be3d6a6131c61fa7 X-Google-Attributes: gid1164f8,public From: Andy Freeman Subject: Re: Did Intel pay UGS to kill Alpha port? Or Compaq simply doesn't care? Date: 1999/04/13 Message-ID: <7evlol$1td$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 465888060 References: <36E9F2A0.9A401A09@pacific.net.sg> <7cj96m$h07$1@plonk.apk.net> <7eih45$ln2$1@news.doit.wisc.edu> <7eu1cd$ils$1@m2.c2.telstra-mm.net.au> X-Http-Proxy: 1.0 x3.dejanews.com:80 (Squid/1.1.22) for client 38.28.78.131 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Tue Apr 13 14:53:13 1999 GMT Newsgroups: comp.arch,comp.sys.dec,vmsnet.alpha X-Http-User-Agent: Mozilla/4.04 [en] (Win95; U) In article <7eu1cd$ils$1@m2.c2.telstra-mm.net.au> reilly@zeta.org.au wrote: > In article handleym@ricochet.net (Maynard Handley) writes: > > #if DEBUG > > #define FLAG_ERROR(error) if(error!=noErr) Debugger() > > #else > > #define FLAG_ERROR(error) > > #endif > > > > error=CallSomeFunc(...); > > FLAG_ERROR(error); > > Catching errors early is obviously a good thing, but how is this > mechanism different from using an assert() in the code that is > generating the condition code in the first place? (1) It isn't nececessarily an error, but a condition that some callers of CallSomeFunc know how to handle. (2) CallSomeFunc is a standard library subroutine or otherwise separately compiled so that it doesn't signal errors. BTW - The FLAG_ERROR approach has the benefit that its behavior doesn't depend on DEBUG when the condition does not hold. assert() doesn't work that way. (To see why, look at what happens with assert(!CallSomeFunc()).) assert() is the sort of "design" which happens when you optimize at the wrong level, in this case because some "important" compiler might not remove dead-code. In other words, assert() makes it awkward to write "evaluate, and if DEBUG is set and an error occurs...." It only lets you write, "if DEBUG is set and an error occurs...." The former can be easily sprinkled through code, using the latter requires work (and can introduce bugs), so it doesn't happen. -andy -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own