From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,db5c6b2ef47d4b9e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-22 14:50:18 PST Newsgroups: comp.lang.ada From: Ted Dennison References: <3B30F836.D700DAA3@raytheon.com> <3B312260.728686B5@boeing.com> <5ee5b646.0106221258.601d2bce@posting.google.com> Subject: Re: short-circuit control forms Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Fri, 22 Jun 2001 17:49:41 EDT Organization: http://www.newsranger.com Date: Fri, 22 Jun 2001 21:49:41 GMT Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!netnews.com!feed.cgocable.net!out.nntp.be!propagator-dallas!news-in-dallas.newsfeeds.com!news.bnb-lp.com!newsranger.com!www.newsranger.com!not-for-mail Xref: archiver1.google.com comp.lang.ada:9050 Date: 2001-06-22T21:49:41+00:00 List-Id: In article <5ee5b646.0106221258.601d2bce@posting.google.com>, Robert Dewar says... >It is quite obvious that in some cases short circuiting is critical >for efficiency without needing detailed measurements. For example, >when searching in a binary tree, it can make the difference between >O(logN) and O(N) behavior in extreme cases (well in recursion cases But if the binary tree isn't ever that large, then it might not be "critical for efficiency" at all. However, in this case I'd agree with you completely that you should probably still go with the short-circuit in the first place. Then again, this is a bit of a strawman argument. What are you doing using a binary-tree instead of a simple linear linked-list in the first place, if the performance hasn't already been determined to be "critical for efficiency"? It seems in this case you have already started looking at efficiency, so its fairly easy to agree with you that this is a case where its sensible to keep such details in mind. I have to wonder how much of the sides people take on this issue has to do with the kind of applications they generally develop. The short-circuitist approach does have the benifit of minimizing *average* runtime for an application. That is a damn important number for anyone writing CPU-limited input processing application like a compiler. However, for us folks doing real-time work, we don't care at all about that number. What we have to worry about is meeting a deadline in the *worst* case (or the deadline - our targeted spare). If we do meet that deadline, great. If we don't, its usually due to one or two horribly inneficient constructs somewhere in a tight loop, and the odds of it being a non-short-circuit is pretty slim (could happen, but I haven't see it yet). The other problem we have to deal with occasionaly is jitter (a routine taking a variying time to complete, causing noticeble time variations somewhere else). That issue is actualy made a smidge *worse* using a short-circuited construct. Anyway, it seems that, of the positions I can identify, the most vocal short-circuitists are compiler writers, and the most vocal nonshort-circuiters are real-time programmers. But perhaps my analysis is a bit off, and the truth of the matter is that you compiler writers just happen to be much more knowledgable than us real-time developers. After all, at you are at least smart enough to work on a system that can be used and debugged on your host machine. We have to walk over to labs or fly halfway around the world just to try out our code properly. How stupid is that? :-) --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com