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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.68.247.138 with SMTP id ye10mr10644pbc.6.1412974546048; Fri, 10 Oct 2014 13:55:46 -0700 (PDT) X-Received: by 10.140.89.239 with SMTP id v102mr31852qgd.34.1412974545789; Fri, 10 Oct 2014 13:55:45 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!uq10no8190061igb.0!news-out.google.com!i10ni77qaf.0!nntp.google.com!dc16no1938057qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Oct 2014 13:55:45 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.53.78.59; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 206.53.78.59 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8d6fe2a6-a8fa-441f-8b35-fc5a744359fb@googlegroups.com> Subject: Type extension and discriminants From: sbelmont700@gmail.com Injection-Date: Fri, 10 Oct 2014 20:55:45 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:189637 Date: 2014-10-10T13:55:45-07:00 List-Id: 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 pack= age A, and then T2 which extends T1 in package B. T2 can't see which (if a= ny) discriminants T1 actually has, so it stands to reason T2 must be also d= eclared with unknown discriminants (perhaps implicitly, given 3.7~26: "if d= erived, such a type has the same sort of discriminants (known, unknown, or = none) as its parent (or ancestor) type"). Consequently, any constructor fu= nction that builds a T2 would need to use an extension aggregate, specifyin= g one of T1's constructor functions to build the unknown parts. This is wh= at 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 n= eeding to define T1's discriminants, which it could not since it has no ide= a if they exist or not. Seemingly the best it could do is create discrimin= ants for whatever arguments T1's constructor function would need, and use t= hose 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 preven= ts these sort of constructs? -sb