comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: What is wrong here? (Generic and controlled types)
Date: 2000/04/03
Date: 2000-04-03T00:00:00+00:00	[thread overview]
Message-ID: <8caebe$6us$1@nnrp1.deja.com> (raw)
In-Reply-To: 38E871E6.8D9EBE71@lufmech.rwth-aachen.de

In article <38E871E6.8D9EBE71@lufmech.rwth-aachen.de>,
Alexander Boucke <alexb@lufmech.rwth-aachen.de> wrote:
> Hello!
>
> I am writing a vector-package using controlled types.
> I implemented some sort of reference-counting to access
> the arrays. This is why I used the controlled types and
> do not access the arrays directly. A non-generic version
> of the packge is running fine and giving good
> improvements in speed and memory-usage against the
> "trivial" implementation.
>
> While converting the package to be generic I encounter
> an error while compiling my test-program. I must admit,

> 29. package Real_Vectors is new Generic_Vectors(Real, Index, Zero);
> |
> >>> instantiation error at generic_vectors.ads:23
> >>> controlled type must be declared at the library level
> >>> instantiation error at generic_vectors.ads:75
> >>> controlled type must be declared at the library level

:-)

I posted here with almost exactly the same question about 3 months ago.
You can't derive a type from a tagged type at a lower visibility level
than the parent tagged type is declared at. Since controlled types are
tagged and declared directly within a package spec, any types derived
from a controlled type must be declared within a library-level package
spec or body. That means controlled types are not useable if you want to
define your type in a local generic. :-(

The good news is that since this was just a test program, there's a
decent chance you will never again need to instantiate a your generic in
a procedure. If that's the case, just declare a package spec to be the
instantiation of your generic, and you can go on your merry way.

I personally feel Ada really falls on its face here. The only time I
ever felt I needed to create a controlled type was in this context.

--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-04-03  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-03  0:00 What is wrong here? (Generic and controlled types) Alexander Boucke
2000-04-03  0:00 ` Ted Dennison [this message]
2000-04-03  0:00   ` Ehud Lamm
2000-04-03  0:00   ` Robert Dewar
2000-04-03  0:00     ` Ted Dennison
2000-04-03  0:00     ` swhalen
2000-04-06  0:00       ` Robert Dewar
2000-04-03  0:00     ` Florian Weimer
2000-04-03  0:00       ` tmoran
2000-04-04  0:00       ` Alexander Boucke
2000-04-06  0:00       ` Robert Dewar
2000-04-21  0:00         ` Florian Weimer
2000-04-04  0:00     ` Robert A Duff
2000-04-06  0:00       ` Robert Dewar
2000-04-06  0:00       ` Mats Weber
2000-04-06  0:00         ` Robert Dewar
2000-04-06  0:00           ` Robert A Duff
2000-04-06  0:00             ` Robert Dewar
2000-04-21  0:00     ` Vincent Marciante
2000-04-21  0:00       ` Robert Dewar
2000-04-21  0:00         ` Robert Dewar
2000-04-22  0:00         ` Vincent Marciante
2000-04-22  0:00           ` Robert Dewar
2000-04-04  0:00   ` Alexander Boucke
2000-04-06  0:00     ` Robert Dewar
replies disabled

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