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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bfbc780dd8e1c97c X-Google-Attributes: gid103376,public From: adam@irvine.com Subject: Re: Question about generic formal derived types Date: 1999/03/30 Message-ID: <7drjqu$bq4$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 460908619 References: <7dpgl4$h2j$1@nnrp1.dejanews.com> X-Http-Proxy: 1.0 x9.dejanews.com:80 (Squid/1.1.22) for client 192.160.8.21 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Tue Mar 30 22:39:27 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/3.0 (X11; I; Linux 2.0.34 i686) Date: 1999-03-30T00:00:00+00:00 List-Id: In article , Stephen Leake wrote: > > After adding a spec for Pack4, running this thru ObjectAda 7.1.2 gives > the error: > > adam.adb: Error: line 32 col 67 LRM:8.3(26), Illegal to override > declaration in same region, Introducing new declaration anyway > (In instance of generic Pack2 at adam.adb: line 13 col 9) > > I believe that answers all your questions :). > > -- Stephe I hope the smiley means you were kidding. Certainly, just running it through a compiler and seeing what the compiler says doesn't really answer any questions, since the Ada language rules are not determined by what a specific compiler says they are or aren't. (This principle might not apply to other languages. :-)) Besides, the error message doesn't say what "declaration" it considers illegal, and the line number doesn't help because you had to add some text to my fragment. I did look at 8.3(26), but it's taken me a while to figure out whether it applies to the two components with the same name, and I'm still not sure. 8.3(26) refers to a homograph being declared in the same declarative region, but the definition of "declarative region" in 8.1(1-11) doesn't give any indication that component names in a type extension belong to the same declarative region. I had to stumble across 3.4(14) to find out that the components of a parent type are considered to be implicit declarations in the declarative region of the derived type. (From what I can find, it appears that 3.4(14) and 8.3(26) taken together are the way we know that a component in a type extension can't have the same name as a component of the parent type, in contrast to 3.8(9) which says, probably redundantly, that two components of a record type can't have the same name.) Anyway, figuring out how this applies to a generic isn't trivial. 8.3(26) doesn't seem to help since the name being defined twice is neither a dispatching operation nor an overloadable declaration. 12.3(11) seems to be the key here, saying that Legality Rules (of which 8.3(26) is one) are enforced at the time of instantiation for the visible part of an instance. But then we have to deal with 12.3(18), which seems like it might imply that one declaration of Field3 might override the other, since (according to 3.4(14)) the component declarations inherited from a parent type are *implicit* declarations in the declarative region of the derived type. Then there's 12.3(11.v) in the AARM, which seems like it might clarify things, assuming I'm interpreting it correctly, which I'm not sure about. So after reading everything, it looks like the intent is to make this instantiation illegal because of the name conflict, although it seems to be the only way I can think of that a generic instantiation can be illegal for this reason. This last makes me skeptical that this was what the language designers intended, which is why I'm hoping for an "official" answer from someone in the know (i.e. a human someone, not a compiler someone). -- Adam -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own