From stt@dsd.camb.inmet.com Thu Apr 6 10:28:18 1995 Return-Path: Received: from inmet.camb.inmet.com by dsd.camb.inmet.com (4.1/SMI-4.1) id AA13633; Thu, 6 Apr 95 10:28:18 EDT Received: from dsd.camb.inmet.com by inmet.camb.inmet.com (4.1/SMI-4.1) id AA15440; Thu, 6 Apr 95 10:28:17 EDT Received: from spock.camb.inmet.com.i2ada by dsd.camb.inmet.com (4.1/SMI-4.1) id AA13630; Thu, 6 Apr 95 10:28:15 EDT Date: Thu, 6 Apr 95 10:28:15 EDT From: stt@dsd.camb.inmet.com (Tucker Taft) Message-Id: <9504061428.AA13630@dsd.camb.inmet.com> To: ada9x-mrt@inmet.camb.inmet.com, jj@ddci.dk Subject: Re: overriding in body Cc: jut@ddci.dk !topic overriding in body !reference AARM95-7.3.1(7p);6.0 !reference 95-5115.a Jesper Joergensen 95-04-05 !from Tucker Taft 95-04-06 <> !discussion > Until yesterday we thought that 3.9.2(13) "the explicit declaration of a > primitive subprogram of a tagged type shall occur before > ... the type is frozen..." > ensured that we could build the dispatch table for a tagged type declared in a > package specification based upon information from the package specification > alone. It seems, however, that there are cases where we need information from > the corresponding package body. Your example below is correct. However, there is no "information" coming from the package body. It just happens to be the place where the implicit declaration (which is overridden by the earlier explicit declaration) occurs. > Consider a modification of the example in 7.3.1(7d-7k): > > > package Parent is > type Root is tagged null record; > private > procedure Op2( X : Root ); -- private primitive for Root > end Parent; > > > package Parent.Child is > package Nested is > type T4 is new Root with null record; > -- T4 inherits Op2, but Op2 isn't declared until the body > private > procedure Op2( X : T4 ); -- overrides, BUT NOT YET > end Nested; > private > -- nothing interesting happens to Op2 here > end Parent.Child; > > > package body Parent.Child is > package body Nested is > -- Here the derived Op2 gets declared and immediately overridden. > -- That means that the explicit Op2 overrides the inherited also in the > -- dispatch table for T4!? > procedure Op2( X : T4 ) is > begin > null; > end Op2; > end Nested; > end Parent.Child; > > > Since the explicitly declared Op2 overrides the implicitly declared one, > 3.9.2(20) says that the body to execute for a call on T4's Op2 is that in the > body of Nested. Was this the intention and doesn't it violate the second > principle of 3.9.2(13a) and make 3.9.2(13d) = false? This was the intent. It doesn't violate the second principle of 3.9.2(13b), nor make 3.9.2(13e) false, [are you using an older version of the AARM?], because the link-name of the overriding Op2 is known at the time the type descriptor needs to be built. > Of course, you could say that from the package specification alone we can see > that when the body for Nested comes, there will be an overriding, but it needs > a twist in the code to implement this. Perhaps, but this "twist" is necessary to correctly implement the semantics. The expected implementation was that at the point of the derivation, all primitives that would eventually be inherited will be identified by the compiler. Their implicit declarations might be postponed, but the compiler needs to know what primitives "exist" and will "eventually" be declared to make appropriate choices about which "dispatching slot" to assign to each explicitly declared primitive subprogram. > Or am I missing some rule that prevents an overriding to happen in the body? The overriding doesn't really "happen" in the body. The implicit declaration, wherever it occurs, is overridden by the explicit declaration (which must be in the spec somewhere if the tagged type declaration is). -Tuck