comp.lang.ada
 help / color / mirror / Atom feed
* Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming?
@ 2003-01-13  6:05 Grein, Christoph
  2003-01-14  6:04 ` Richard Riehle
  0 siblings, 1 reply; 6+ messages in thread
From: Grein, Christoph @ 2003-01-13  6:05 UTC (permalink / raw)


From: kcline17@hotmail.com (Kevin Cline)

> 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.

This C++ feature pleases me so that I'm apt to wish something like it were 
available in Ada.

However I have not thought about all implications this would induce in 
connection with all other features in Ada, so this might turn out to be a kind 
of Pandora's box.

It is true, there are some places in Ada where implicit declarations or type 
conversions are done, but implicit instantiations are as yet nowhere.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming?
  2003-01-13  6:05 Grein, Christoph
@ 2003-01-14  6:04 ` Richard Riehle
  2003-01-14 20:25   ` Kevin Cline
  2003-01-14 21:12   ` Hyman Rosen
  0 siblings, 2 replies; 6+ messages in thread
From: Richard Riehle @ 2003-01-14  6:04 UTC (permalink / raw)


"Grein, Christoph" wrote:

> It is true, there are some places in Ada where implicit declarations or type
> conversions are done, but implicit instantiations are as yet nowhere.

Implicit type conversions, along with implicit type promotions run
counter to the Ada philosophy.

C++ does not provide the same kind of capability for declaring new
numeric types one has in Ada.   This, in spite of the entertaining
example from Mr. Rosen.

Typedef does not do the same thing.   We are still left with predefined
types.

The whole idea of Ada is to declare types so they will be checked by
the compiler and so mismatches will be caught.   If there is a problem
with that, in the current standard, it needs to be fixed, but implicit
conversions or promotions is simply a bad idea for this language.

Actually, I don't think there is really a problem here wrt Ada, even
after reading your paper.

Richard Riehle







^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming?
@ 2003-01-14  6:29 Grein, Christoph
  2003-01-15  4:35 ` Richard Riehle
  0 siblings, 1 reply; 6+ messages in thread
From: Grein, Christoph @ 2003-01-14  6:29 UTC (permalink / raw)


> "Grein, Christoph" wrote:
> 
> > It is true, there are some places in Ada where implicit declarations or type
> > conversions are done, but implicit instantiations are as yet nowhere.
> 
> Implicit type conversions, along with implicit type promotions run
> counter to the Ada philosophy.
> 
> C++ does not provide the same kind of capability for declaring new
> numeric types one has in Ada.   This, in spite of the entertaining
> example from Mr. Rosen.
> 
> Typedef does not do the same thing.   We are still left with predefined
> types.
> 
> The whole idea of Ada is to declare types so they will be checked by
> the compiler and so mismatches will be caught.   If there is a problem
> with that, in the current standard, it needs to be fixed, but implicit
> conversions or promotions is simply a bad idea for this language.
> 
> Actually, I don't think there is really a problem here wrt Ada, even
> after reading your paper.
> 
> Richard Riehle

Richard,

from where in my paper do you get the impression that I might think there is a 
problem with Ada? I only state that there is no good way to do dimension 
checking during compile-time.

I find the C++ example doing compile-time checking intriguing and I thought it 
might be nice to have something like this in Ada. My concern was that adding 
implicit instantiations to Ada might harm other parts of the language. So we 
have 
the same opinion wrt this point.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for  a beginner to programming?
  2003-01-14  6:04 ` Richard Riehle
@ 2003-01-14 20:25   ` Kevin Cline
  2003-01-14 21:12   ` Hyman Rosen
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Cline @ 2003-01-14 20:25 UTC (permalink / raw)


Richard Riehle <richard@adaworks.com> wrote in message news:<3E23A88A.2C0969B0@adaworks.com>...
> "Grein, Christoph" wrote:
> 
> > It is true, there are some places in Ada where implicit declarations or type
> > conversions are done, but implicit instantiations are as yet nowhere.
> 
> Implicit type conversions, along with implicit type promotions run
> counter to the Ada philosophy.

> C++ does not provide the same kind of capability for declaring new
> numeric types one has in Ada.   This, in spite of the entertaining
> example from Mr. Rosen.

C++ doesn't provide them explicitly.  But writing classes which
mimic Ada's numeric types is not difficult.  The C++ philosophy
is generally not to add features to the language which can be easily 
provided by a library.
 
> The whole idea of Ada is to declare types so they will be checked by
> the compiler and so mismatches will be caught.   If there is a problem
> with that, in the current standard, it needs to be fixed, but implicit
> conversions or promotions is simply a bad idea for this language.

No one wants implicit conversions or promotions.  But implicit 
instantiation of generic types would aid the development of type-safe code.

> Actually, I don't think there is really a problem here wrt Ada, even
> after reading your paper.

Given that strong type checking was a main goal in Ada's design, I think
Ada's inability to do compile-time validation of computations
involving physical units should be considered a rather serious flaw
in the language.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for  a beginner to programming?
  2003-01-14  6:04 ` Richard Riehle
  2003-01-14 20:25   ` Kevin Cline
@ 2003-01-14 21:12   ` Hyman Rosen
  1 sibling, 0 replies; 6+ messages in thread
From: Hyman Rosen @ 2003-01-14 21:12 UTC (permalink / raw)


Richard Riehle wrote:
> Implicit type conversions, along with implicit type promotions run
> counter to the Ada philosophy.

True, but irrelevant to the Unit C++ code, which does not involve
any implicit type conversions. (I should have declared my constructors
explicit, and special-cased Unit<Type,0,0,0> to allow an implicit
conversion from Type. But my example was just a rough outline.)

> C++ does not provide the same kind of capability for declaring new
> numeric types one has in Ada.   This, in spite of the entertaining
> example from Mr. Rosen.

But it does have the capability for declaring new class types,
and that's what the Unit code uses.

> Typedef does not do the same thing.   We are still left with predefined
> types.

I was typedefing class types, not numeric types. My typedefs were
just mnemonic shorthand for the full Unit<...> types.

> The whole idea of Ada is to declare types so they will be checked by
> the compiler and so mismatches will be caught.   If there is a problem
> with that, in the current standard, it needs to be fixed, but implicit
> conversions or promotions is simply a bad idea for this language.

And that is precisely what the C++ code is doing. At compile time,
and with zero run-time size or space overhead, the compiler will
catch attempts to add or subtract mismatched units, or to assign
one unit type to a different one. Multiplication or division of
units automatically produces a correct result type, and you can
have arbitrarily complex expressions, all checked by the compiler.

There are absolutely no implicit conversions or promotions involved.

> Actually, I don't think there is really a problem here wrt Ada, even
> after reading your paper.

Except that you can't do this in Ada, and people want to.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming?
  2003-01-14  6:29 Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming? Grein, Christoph
@ 2003-01-15  4:35 ` Richard Riehle
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Riehle @ 2003-01-15  4:35 UTC (permalink / raw)


"Grein, Christoph" wrote:

> > "Grein, Christoph" wrote:
> >
> > > It is true, there are some places in Ada where implicit declarations or type
> > > conversions are done, but implicit instantiations are as yet nowhere.
> >
> > Implicit type conversions, along with implicit type promotions run
> > counter to the Ada philosophy.
> >
> > C++ does not provide the same kind of capability for declaring new
> > numeric types one has in Ada.   This, in spite of the entertaining
> > example from Mr. Rosen.
> >
> > Typedef does not do the same thing.   We are still left with predefined
> > types.
> >
> > The whole idea of Ada is to declare types so they will be checked by
> > the compiler and so mismatches will be caught.   If there is a problem
> > with that, in the current standard, it needs to be fixed, but implicit
> > conversions or promotions is simply a bad idea for this language.
> >
> > Actually, I don't think there is really a problem here wrt Ada, even
> > after reading your paper.
> >
> > Richard Riehle
>
> Richard,
>
> from where in my paper do you get the impression that I might think there is a
> problem with Ada? I only state that there is no good way to do dimension
> checking during compile-time.
>
> I find the C++ example doing compile-time checking intriguing and I thought it
> might be nice to have something like this in Ada. My concern was that adding
> implicit instantiations to Ada might harm other parts of the language. So we
> have the same opinion wrt this point.

Chris,

Sorry if I misread something in your paper.

Richard







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-01-15  4:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-14  6:29 Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming? Grein, Christoph
2003-01-15  4:35 ` Richard Riehle
  -- strict thread matches above, loose matches on Subject: below --
2003-01-13  6:05 Grein, Christoph
2003-01-14  6:04 ` Richard Riehle
2003-01-14 20:25   ` Kevin Cline
2003-01-14 21:12   ` Hyman Rosen

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