comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: "with private" required in generic formal type parameter
Date: 1997/01/17
Date: 1997-01-17T00:00:00+00:00	[thread overview]
Message-ID: <E46276.Ist@world.std.com> (raw)
In-Reply-To: 853519646.32574@dejanews.com


In article <853519646.32574@dejanews.com>,  <m193884@csehp1.mdc.com> wrote:
>I'm not arguing that it shouldn't be required, since it appears to enhance 
>readability.  I'm just curious as to what compiler problem "with private" 
>solves in this example that would be there without it.

It does not solve any compiler problem.  The rule is there for
readability (it's nice to know whether the thing is tagged or not, from
the syntax), and for consistency (it's nice that every tagged type
derivation has "with ..." and every untagged type derivation does not).
Generic formal types are sort of analogous to package-private
types/extensions, in an "inside-out" way, with the actual type of a
generic formal corresponding to the full type of a package-private type.
So we want the syntax to be consistent.  In a package visible part, if
T1 is tagged, you say:

    type T2 is new T1 with private;

or

    type T2 is new T1 with record ...; -- Or "with null record".

And the compiler has to know the difference -- the former means more is
coming later.  If you could leave out the "with ...", then what should
it mean to say "type T2 is new T1;"?  Does that mean "with null record"
or "with private"?  One would guess the former, I think.  But it would
be inconsistent for "type T2 is new T1;" to mean one thing (no added
components) in a package, and a different thing (added components will
come from the actual) in a generic.  Hence, "with <something>" should
always be required.

- Bob




      reply	other threads:[~1997-01-17  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-17  0:00 "with private" required in generic formal type parameter m193884
1997-01-17  0:00 ` Robert A Duff [this message]
replies disabled

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