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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7f2ce8bda9cae4ab X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!news-toy.newsread.com!netaxs.com!newsread.com!POSTED.monger.newsread.com!not-for-mail Newsgroups: comp.lang.ada Subject: Re: "Must instantiate controlled types at library level." Why? From: "Peter C. Chapin" References: Organization: Kelsey Mountain Software Message-ID: User-Agent: Xnews/5.04.25 Date: Wed, 12 May 2004 10:47:47 GMT NNTP-Posting-Host: 216.114.178.163 X-Complaints-To: Abuse Role , We Care X-Trace: monger.newsread.com 1084358867 216.114.178.163 (Wed, 12 May 2004 06:47:47 EDT) NNTP-Posting-Date: Wed, 12 May 2004 06:47:47 EDT Xref: controlnews3.google.com comp.lang.ada:474 Date: 2004-05-12T10:47:47+00:00 List-Id: Jeffrey Carter wrote in news:NJeoc.16758$V97.5496 @newsread1.news.pas.earthlink.net: > The call to Library_Level.Op would attempt to dispatch to > Outer.Inner.Op, which is out of scope. The references to I in > Outer.Inner.Op refer to a variable that no longer exists. Thank you for your detailed post. It was very helpful. I haven't yet gotten around to studying Ada's object oriented features in detail but I can see that the issue is related to the fact that Ada allows procedures to be defined inside other procedures. Just for fun I attached an equivalent C++ program below. Interestingly, it seems to compile and work using three different C++ compilers. I wonder its behavior is technically "undefined". It seems like it probably should be. Perhaps I'll ask on the C++ group. Peter -----> cut <----- #include class X { public: virtual void f(); }; void X::f() { std::cout << "I'm in X::f\n"; } X *ptr; void helper() { class Y : public X { public: virtual void f() { std::cout << "I'm in Y::f\n"; } }; ptr = new Y; } int main() { helper(); ptr->f(); return 0; }