comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert C. Leif" <rleif@rleif.com>
Subject: Dimension checking was RE: Why is Ada NOT a good choice for a beginner to programming?
Date: Sat, 11 Jan 2003 10:32:56 -0800
Date: 2003-01-11T10:32:56-08:00	[thread overview]
Message-ID: <mailman.1042310041.30777.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <ba162549.0301100751.5e21e05c@posting.google.com>

An obvious fix, which was discussed at SIGAda 2002, is to develop a means
(Pragma?) to tell the compiler to only check the dimensionality at compile
time. This could be in the form of a compile time assertion.
Bob Leif

-----Original Message-----
From: comp.lang.ada-admin@ada.eu.org [mailto:comp.lang.ada-admin@ada.eu.org]
On Behalf Of Kevin Cline
Sent: Friday, January 10, 2003 7:51 AM
To: comp.lang.ada@ada.eu.org
Subject: Re: Why is Ada NOT a good choice for a beginner to programming?

"Grein, Christoph" <christoph.grein@eurocopter.com> wrote in message
news:<mailman.1042181162.27181.comp.lang.ada@ada.eu.org>...
> > > One complaint he had was that it be possible to define a Length
> > > using derived types and still have "*" return values of type Length,
> > > when it should return an area.  He had a point, hadn't he?
> > > OTOH, with only structural equivalence of types, and no way to derive
> > > both an integral length type and an integral area type, that are
really
> > > diferent, how can you build areas into your types, such that the
compiler
> > > will prevent use of values of the wrong type?
> > > 
> > > In which languages has this been fixed?
> > 
> > This is relatively easy to do in C++.
> > See
http://www.fnal.gov/docs/working-groups/fpcltf/html/SIunits-summary.html
> 
> This is also easy in Ada.
> 
> For a collection of methods how to deal with dimensions in Ada, see
> <http://home.T-Online.de/home/Christ-Usch.Grein/Ada/Dimension.html>

Did you read Grein's paper?  He says that it was not easy at all.

Grein writes:

  But the request to have full dimensional checking persists as can be seen
  from the pertinent discussions in newsgroup Comp.Lang.Ada. There are two
  basic ways one can try to solve the problem, either by adding to the
  numeric value its dimension as attribute, or by using different types for
  different dimensions.  Since the first method is runtime-consuming,
  whereas the second one is only compiletime-consuming, all effort naturally
  concentrates on the second method.   This is doomed to fail
  as is shown in the paper cited above - although a plethora of overloaded
  operations is used, the result is not really satisfactory.
  Physical equations with all their powers and roots evade these attempts.

In short, Ada's requirement for explicit generic instantiation repels
attempts to create a compile-time verified system of dimensional types,
and Grein gave up on attempts to achieve compile-time type safety.

C++ does not have this problem, and compile-time type safety is
achieved in a fairly obvious way.




  reply	other threads:[~2003-01-11 18:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-10  6:38 Why is Ada NOT a good choice for a beginner to programming? Grein, Christoph
2003-01-10  8:21 ` Hyman Rosen
2003-01-10 15:51 ` Kevin Cline
2003-01-11 18:32   ` Robert C. Leif [this message]
2003-01-13 17:34     ` Dimension checking was " Stephen Leake
2003-01-13 23:20     ` Kevin Cline
2003-01-10 19:00 ` Kevin Cline
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox