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,a01d08518b83ef44 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: "with private" required in generic formal type parameter Date: 1997/01/17 Message-ID: #1/1 X-Deja-AN: 210480564 references: <853519646.32574@dejanews.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1997-01-17T00:00:00+00:00 List-Id: In article <853519646.32574@dejanews.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 " should always be required. - Bob