comp.lang.ada
 help / color / mirror / Atom feed
* "with private" required in generic formal type parameter
@ 1997-01-17  0:00 m193884
  1997-01-17  0:00 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: m193884 @ 1997-01-17  0:00 UTC (permalink / raw)



I created a generic package with one generic parameter, like so:

generic
    type A is new B;
package C is ....

where B is a tagged type.

The compiler flagged the generic parameter with the following words:

"A record_extension_part shall be provided if and only if the parent type
is a tagged type"

I found the validity of this in LRM 12.5 and according to my reading the
compiler is correct.

What I'm curious about is:  _why_ is this restriction needed?  Doesn't the
compiler already know that the formal is tagged and the actual must be?  
My understanding is, moreover, that any actual must be derived from B.

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.
-- 
James Squire           mailto:m193884 no junk mail allowed@csehp1.mdc.com
MDA Avionics Tools & Processes
McDonnell Douglas Aerospace              http://www.mdc.com/
Opinions expressed here are my own and NOT my company's
"We'll strike back and we'll strike back hard!"
	-- Londo, "Midnight on the Firing Line"
-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: "with private" required in generic formal type parameter
  1997-01-17  0:00 "with private" required in generic formal type parameter m193884
@ 1997-01-17  0:00 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 1997-01-17  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-01-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-17  0:00 "with private" required in generic formal type parameter m193884
1997-01-17  0:00 ` Robert A Duff

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