From: Warren <ve3wwg@gmail.com>
Subject: Re: Ada Smileys in C++ lib Conversion
Date: Fri, 13 Aug 2010 18:36:38 -0700 (PDT)
Date: 2010-08-13T18:36:38-07:00 [thread overview]
Message-ID: <b05a83d9-fac1-45cb-91c5-f99516ca27f2@k10g2000yqa.googlegroups.com> (raw)
In-Reply-To: 9b88e5a4-c588-4997-ad5c-2efa216fe4f4@a4g2000prm.googlegroups.com
On Aug 13, 12:53 pm, Anh Vo <anhvofrc...@gmail.com> wrote:
> On Aug 13, 7:20 am, Warren <ve3...@gmail.com> 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
next prev parent reply other threads:[~2010-08-14 1:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-13 14:20 Ada Smileys in C++ lib Conversion Warren
2010-08-13 15:06 ` Yannick Duchêne (Hibou57)
2010-08-13 16:53 ` Anh Vo
2010-08-14 1:36 ` Warren [this message]
2010-08-14 9:52 ` Georg Bauhaus
2010-08-14 10:57 ` Brian Drummond
2010-08-14 20:34 ` Maciej Sobczak
2010-08-14 21:01 ` Dmitry A. Kazakov
2010-08-15 1:16 ` Brian Drummond
2010-08-15 10:04 ` Maciej Sobczak
2010-08-16 12:08 ` Brian Drummond
2010-08-16 12:13 ` Georg Bauhaus
2010-08-16 12:30 ` Brian Drummond
2010-08-16 12:39 ` Maciej Sobczak
2010-08-16 21:39 ` Brian Drummond
2010-08-16 22:53 ` Robert A Duff
2010-08-24 10:12 ` David Thompson
2010-08-30 9:51 ` Brian Drummond
2010-08-16 14:54 ` Warren
2010-08-16 20:27 ` Maciej Sobczak
2010-08-17 12:57 ` Warren
2010-08-17 13:37 ` Maciej Sobczak
2010-08-17 15:07 ` Georg Bauhaus
2010-08-18 17:31 ` Warren
2010-08-24 10:12 ` David Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox