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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,25aa3c7e1b59f7b5,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-03 12:28:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0900.news.uu.net!reader0901.news.uu.net!not-for-mail Message-ID: <3C34BF2C.6030500@mail.com> Date: Thu, 03 Jan 2002 15:29:32 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.7+) Gecko/20011228 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: A case where Ada defaults to unsafe? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1010089734 reader1.ash.ops.us.uu.net 4569 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:18486 Date: 2002-01-03T15:29:32-05:00 List-Id: The conventional belief (at least on CLA :-) is that one of the main distinctions between Ada and C/C++ is that Ada defaults to safe behavior and C/C++ defaults to unsafe behavior (eg., array indexing, automatic type conversions, and overflow checking). It occurs to me that there is a case where the opposite seems to be true. In C/C++, the && and || binary operators short-circuit, evaluating their right operand only if necessary. In Ada, it is necessary to specify "and then" and "or else" for this behavior, otherwise the order of evaluation of the two sides is unspecified if the simple "and" and "or" forms are used. So in Ada, one could say 'if a /= 0 and b/a > 3' and fall into a trap that would not happen in C/C++. Discuss?