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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!matrix.darkstorm.co.uk!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Type extension and discriminants Date: Fri, 10 Oct 2014 17:34:52 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <8d6fe2a6-a8fa-441f-8b35-fc5a744359fb@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1412980493 5281 69.95.181.76 (10 Oct 2014 22:34:53 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 10 Oct 2014 22:34:53 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:22336 Date: 2014-10-10T17:34:52-05:00 List-Id: It would have helped a bit had you given an example. I'm presuming you're talking about something like: package P1 is type T (<>) is tagged private; ... end P1; with P1; package P2 is type NT (???) is new P1.T with private; .... end P2; and you want to know how NT is declared. If you had: type NT (D : E) is new P1.T with private; RM 3.7(12-13) would be violated, so this is illegal. If you had: type NT (D : E) is new P1.T (D) with private; At least RM 3.7(15) would be violated (and there are probably more), so this is also illegal. As you noted, 3.7(26) says that type NT is new P1.T with private; has unknown discriminants, so this declaration is legal. As you note, you'd need an extension aggregate to initialize that. I think that should be legal as well (I can't think of a reason off hand that it shouldn't be). I'd rather have the unknown discriminants explicit, as in: type NT(<>) is new P1.T with private; This would need the same kind of extension aggregate. My guess is that you've hit some sort of compiler bug (this is a little used area in my experience), but it's hard to tell without seeing a complete example. Randy. wrote in message news:8d6fe2a6-a8fa-441f-8b35-fc5a744359fb@googlegroups.com... Hi, GNAT is giving me odd errors, strange crashes, and dubious successes, so to be safe I will ask the experts: what are the rules behind extending types with discriminants (specifically unknown) from non-child packages? Consider T1, declared with unknown discriminants in the public part of package A, and then T2 which extends T1 in package B. T2 can't see which (if any) discriminants T1 actually has, so it stands to reason T2 must be also declared with unknown discriminants (perhaps implicitly, given 3.7~26: "if derived, such a type has the same sort of discriminants (known, unknown, or none) as its parent (or ancestor) type"). Consequently, any constructor function that builds a T2 would need to use an extension aggregate, specifying one of T1's constructor functions to build the unknown parts. This is what I would assume, but GNAT crashes when trying to compile such constructs. However, if T2 tries to add discriminants, it would fall into the trap of needing to define T1's discriminants, which it could not since it has no idea if they exist or not. Seemingly the best it could do is create discriminants for whatever arguments T1's constructor function would need, and use those as arguments in the type declaration? As in: type T2 (x : y, a : b) is new T1 (A.T1_Ctor(x)) with ... Is this generally correct, or are there other esoteric problems that prevents these sort of constructs? -sb