* Re: Why is Ada NOT a good choice for a beginner to programming?
@ 2003-01-10 6:38 Grein, Christoph
2003-01-10 8:21 ` Hyman Rosen
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Grein, Christoph @ 2003-01-10 6:38 UTC (permalink / raw)
> > 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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why is Ada NOT a good choice for a beginner to programming? 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-10 19:00 ` Kevin Cline 2 siblings, 0 replies; 7+ messages in thread From: Hyman Rosen @ 2003-01-10 8:21 UTC (permalink / raw) Grein, Christoph wrote: > This is also easy in Ada. No, it is not. Of your referenced approaches, only Macks adopts the spirit of the C++ solution, in which all unit operations are checked at compile-time, and unit objects have no space overhead. And Macks requires a seperate processing step to generate the Ada code, and furthermore results in a combinatorial explosion of declarations. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why is Ada NOT a good choice for a beginner to programming? 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 ` Dimension checking was " Robert C. Leif 2003-01-10 19:00 ` Kevin Cline 2 siblings, 1 reply; 7+ messages in thread From: Kevin Cline @ 2003-01-10 15:51 UTC (permalink / raw) "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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Dimension checking was RE: Why is Ada NOT a good choice for a beginner to programming? 2003-01-10 15:51 ` Kevin Cline @ 2003-01-11 18:32 ` Robert C. Leif 2003-01-13 17:34 ` Stephen Leake 2003-01-13 23:20 ` Kevin Cline 0 siblings, 2 replies; 7+ messages in thread From: Robert C. Leif @ 2003-01-11 18:32 UTC (permalink / raw) 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Dimension checking was RE: Why is Ada NOT a good choice for a beginner to programming? 2003-01-11 18:32 ` Dimension checking was " Robert C. Leif @ 2003-01-13 17:34 ` Stephen Leake 2003-01-13 23:20 ` Kevin Cline 1 sibling, 0 replies; 7+ messages in thread From: Stephen Leake @ 2003-01-13 17:34 UTC (permalink / raw) "Robert C. Leif" <rleif@rleif.com> writes: > 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. Or an ASIS tool that reads structured comments to get the units. -- -- Stephe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Dimension checking was RE: Why is Ada NOT a good choice for a beginner to programming? 2003-01-11 18:32 ` Dimension checking was " Robert C. Leif 2003-01-13 17:34 ` Stephen Leake @ 2003-01-13 23:20 ` Kevin Cline 1 sibling, 0 replies; 7+ messages in thread From: Kevin Cline @ 2003-01-13 23:20 UTC (permalink / raw) "Robert C. Leif" <rleif@rleif.com> wrote in message news:<mailman.1042310041.30777.comp.lang.ada@ada.eu.org>... > 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 I don't know what the proposal encompassed, but it's hard for me to imagine an "obvious" fix to this problem. With physical dimensions we have Qty<L1,M1,T1,...> * Qty<L2,M2,T2,...> => Qty<L1+L2,M1+M2,T1+T2,...> where L1,M1,T1,L2,M2,T2 are the dimensions of length, mass, time, etc. However, there are many systems of physical units in use in different problem domains. For example, it is often convenient to make length and time interchangable. And in matrix algebra we have: innerProduct(Matrix<M,N>, Matrix<N,P>) => Matrix<M,P> Any solution adopted should be able to correctly model both of these type systems. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why is Ada NOT a good choice for a beginner to programming? 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-10 19:00 ` Kevin Cline 2 siblings, 0 replies; 7+ messages in thread From: Kevin Cline @ 2003-01-10 19:00 UTC (permalink / raw) "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> Christopher, I apologize for not noticing that you were referring to your own paper. But in the paper you mention numerous shortcomings of the implementation: "Ada is not suited to handling physical dimensions!" and ...we can include semantic information within variable declarations... g: Meter_Per_Second_2 := 9.81; t: Second := 10.0; s: Meter := 0.5 * g * t**2; It is the programmer's own responsibility that this formula is physically correct, no type checking is done! ...There is one service restriction: Checks in assignments concerning physical dimensions are not performed. The C++ solution affords full compile-time checking of assignments, and will not allow a quantity of one dimensionality to be assigned to a variable of another dimensionality except by resorting to a reinterpret-cast. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-01-13 23:20 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 ` Dimension checking was " Robert C. Leif 2003-01-13 17:34 ` Stephen Leake 2003-01-13 23:20 ` Kevin Cline 2003-01-10 19:00 ` Kevin Cline
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox