From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4bce46ddadaa9806 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: What is wrong here? (Generic and controlled types) Date: 2000/04/03 Message-ID: <8caebe$6us$1@nnrp1.deja.com>#1/1 X-Deja-AN: 606090507 References: <38E871E6.8D9EBE71@lufmech.rwth-aachen.de> X-Http-Proxy: 1.0 x22.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Apr 03 15:45:55 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) Date: 2000-04-03T00:00:00+00:00 List-Id: In article <38E871E6.8D9EBE71@lufmech.rwth-aachen.de>, Alexander Boucke 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.