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-Thread: 103376,2bf2853c7c95c600 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail From: christoph.grein@eurocopter.com Newsgroups: comp.lang.ada Subject: Re: Dispatching operations Date: 8 Nov 2005 04:06:42 -0800 Organization: http://groups.google.com Message-ID: <1131451602.909774.27570@g47g2000cwa.googlegroups.com> References: NNTP-Posting-Host: 80.156.44.1 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1131451608 22319 127.0.0.1 (8 Nov 2005 12:06:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Nov 2005 12:06:48 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 webwasher (Webwasher 5.2.0.1901) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=80.156.44.1; posting-account=nIrLjQ0AAAAgar8ljl4x6DQaFY__mhF4 Xref: g2news1.google.com comp.lang.ada:6281 Date: 2005-11-08T04:06:42-08:00 List-Id: > My confusion is that Op_B is private in P2. X is declared in P2 as well. > In the above call, I'd expect P2.Op_B to be called (which is actually > the case), but since everything is known statically, then I'd expect as > well to get compile-time error due to the fact that P2.Op_B is private. > > In other words: how can I get compile error when calling private P2.Op_B? > If it's not possible, what's the point in making it private? It's irrelevant whether an operation is overridden visibly or privately. Always the overriding operation is called, even if not visible at the place of the call. There are very subtle effects when overriding privately: package P1 is type T1 is tagged null record; procedure Op_B(Arg : in T1; Parm: Integer := 5); end P1; with P1; use P1; package P2 is type T2 is new T1 with null record; private procedure Op_B(Param : in T2; Parm: Integer := 0); end P2; When calling P2.Op_B, it depends on the local visibility at the place of the call which default for Parm is used and which name you have to use in named association for the first parameter. When the private part of P2 is hidden, Op_B (Arg => X) means Op_B (Arg => X, Parm => 5). You do not see the new name of the first parameter. When the private part is visible, Op_B (Arg => X) is wrong; you have to write Op_B (Param => X) which means Op_B (Param => X, Parm => 0). You have to use the new name of the first parameter.