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,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-04 07:16:13 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!hub1.nntpserver.com!peer1-sjc1.usenetserver.com!usenetserver.com!easynews!newsfeed.frii.net!out.nntp.be!propagator-SanJose!in.nntp.be!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3C34BF2C.6030500@mail.com> <3C34D252.4070307@mail.com> <3C34E43E.5070906@mail.com> Subject: Re: A case where Ada defaults to unsafe? 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, 04 Jan 2002 10:16:08 EST Organization: http://www.newsranger.com Date: Fri, 04 Jan 2002 15:16:08 GMT Xref: archiver1.google.com comp.lang.ada:18527 Date: 2002-01-04T15:16:08+00:00 List-Id: In article <3C34E43E.5070906@mail.com>, Hyman Rosen says... > >Ted Dennison wrote: > >> In article <3C34D252.4070307@mail.com>, Hyman Rosen says... >> >>>But get away from C/C++ for a moment. In pure Ada terms, isn't it less safe >>>for the defaults to be "and" and "or" instead of "and then" and "or else"? >>> >> >> Perhaps for ex-C programmers it is. But that's certianly not the only pitfall in >> the language for ex-C programmers. >> >> If you were instead brought up to believe that boolean "and" is communitive, >> like they teach in math/logic classes, then it makes perfect sense. In that >> case, "and then" is just a nice shorthand for " then if ... then". > > >You haven't answered my question, though. Isn't the commutative semantic >less safe than the short circuit one? Yes I have, but I'll do it again: Its only less safe if you are an ex-C programmer that expects the world to look like C. Let's analyze this a little deeper, shall we? Under what conditions is this unsafe? The typical use of "and" and "or" is to perform clasical boolean math, and perhaps to do different things based on the result. Which is more "unsafe" in this typcial circumstance? Neither really. What you are talking about is a different situation where you may realise that something like dereferencing a pointer will cause problems when the pointer is null. So you tell yourself, "self, I'd better prevent an error by first putting in a check to see if the pointer is invalid, then not performing that second operation if that's the case". So you consciously put in the check. So here we are, consciously adding code to implement a "don't do this check unless this other check works out" operation. The only way to screw this up is to use the wrong language features, and the only way we are ever going to do that would be if somewhere along the line something (eg: C) convinced us that these two quite different types of operations are actually the same. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.