comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com
Subject: Re: Question about generic formal derived types
Date: 1999/03/30
Date: 1999-03-30T00:00:00+00:00	[thread overview]
Message-ID: <7drjqu$bq4$1@nnrp1.dejanews.com> (raw)
In-Reply-To: uemm6suip.fsf@gsfc.nasa.gov

In article <uemm6suip.fsf@gsfc.nasa.gov>,
  Stephen Leake <Stephen.Leake@gsfc.nasa.gov> 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    




  reply	other threads:[~1999-03-30  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-30  0:00 Question about generic formal derived types adam
1999-03-30  0:00 ` Stephen Leake
1999-03-30  0:00   ` adam [this message]
1999-03-31  0:00     ` Stephen Leake
1999-03-31  0:00   ` robert_dewar
1999-03-30  0:00 ` Steve Quinlan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox