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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a6fe9ef21ba269dc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!k10g2000yqa.googlegroups.com!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Ada Smileys in C++ lib Conversion Date: Fri, 13 Aug 2010 18:36:38 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1a9b39b0-73f6-497c-a8f4-abf8129886ac@t20g2000yqa.googlegroups.com> <9b88e5a4-c588-4997-ad5c-2efa216fe4f4@a4g2000prm.googlegroups.com> NNTP-Posting-Host: 216.121.235.102 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1281749798 24070 127.0.0.1 (14 Aug 2010 01:36:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 14 Aug 2010 01:36:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k10g2000yqa.googlegroups.com; posting-host=216.121.235.102; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13263 Date: 2010-08-13T18:36:38-07:00 List-Id: On Aug 13, 12:53=A0pm, Anh Vo wrote: > On Aug 13, 7:20=A0am, Warren wrote: > > > > > it immediately identified the value MC_CTL_LOCAL_C > > (and others) as not fitting into the Control_Type's > > valid range. In C++ a glaring error had gone > > unnoticed: > [...] > > I'm always smiling when I convert code from C/C++ to > > Ada. In code of any significant size, Ada always > > discovers problems that went unnoticed in C/C++. > > I am smiling, too, since I am not surprised at all. When someone asks > me what difference between computer languages especially between Ada > and C/C++, I tell him Ada has 75% check at compile time and 25% and > runtime while C/C++ in reverse. > > Anh Vo Heh heh. This is one of those things that C/C++ cannot guard against at all. Unless the value(s) were to exceed the underlying type's storage capability, the compiler is helpless to identify it. There is simply no concept of a "range" of valid values in that language. About the only thing you could do (in C/C++) is to code a macro check on the constants, but I don't think I've ever seen it done in practice. Only as a argument value assertion check in strategic places. But if you leave it up to programmers coding assertions, then you know they won't exist everywhere they're needed. Warren