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.129.81.202 with SMTP id f193mr10111791ywb.83.1498745705640; Thu, 29 Jun 2017 07:15:05 -0700 (PDT) X-Received: by 10.36.34.10 with SMTP id o10mr90365ito.10.1498745705596; Thu, 29 Jun 2017 07:15:05 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!v31no1423431qtb.0!news-out.google.com!s132ni1736itb.0!nntp.google.com!188no93024itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 29 Jun 2017 07:15:05 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=137.103.119.68; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 137.103.119.68 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <82a59ee9-8d55-4c73-9daf-e9f7d9ab8a8f@googlegroups.com> Subject: Re: derived formal types and known discriminants From: sbelmont700@gmail.com Injection-Date: Thu, 29 Jun 2017 14:15:05 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47176 Date: 2017-06-29T07:15:05-07:00 List-Id: On Friday, June 23, 2017 at 1:26:12 PM UTC-4, Randy Brukardt wrote: > > I don't know, I can only guess. And my guess would be that discriminants= =20 > that are added/removed would be a problem. Within the generic, you could= =20 > declare objects giving those discriminant values, but they might not be= =20 > right. For a type with unknown discriminants, you can't declare an object= at=20 > all, so that's easier. >=20 > But why using the same matching rules used for formal private types would= n't=20 > work, I don't know. Or maybe it just didn't seem worth worrying about, gi= ven=20 > that formal derived types are mainly useful to give Steve Baird a rare=20 > mechanism for the amazing semantic issues that he comes up with. (Yes,=20 > formal tagged derived types have some uses in deep type hierarchies, and= =20 > that's about it, because no one declares other kinds of derived types in = the=20 > first place.) >=20 > Randy. You imply that the feature is little-used, but isn't this (one of) the prim= ary mechanisms for MI via the so-called "mixin"? In Mr. Taft's paper from = 1994 ("Multiple Inheritance in Ada 9X"), he lists the three common cases, o= f which #2 is the "generic with a formal derived type" method, i.e. instead= of having C extend both A and B, you make one of the parents a generic tha= t extends a formal derived type of the other, and than have the child and e= xtend that. But if I understand it (quite likely not the case...), this ef= fectively limits this method to parent types without discriminants? For example, suppose I have the abstract type A with some arbitrary discrim= inants, and I extend it into two concrete types Ax and Ay; each has the opt= ion to either inherit the parents discriminants outright, or replace them w= ith their own set (constraining the parent as needed). Now suppose I wish = to extend Ax and Ay into Bx and By, respectively, but also extend them from= an unrelated abstract type W with it's own arbitrary discriminants. I arr= ange W into a generic package with a formal type derived from A, with the i= ntent of instantiating it twice (once on Ax and once on Ay), and then exten= ding each of those to create Bx and By, thus giving me everything from A an= d W together. But now I appear to be stuck, since there's no way to give W discriminants;= doing so requires constraining the discriminants of the formal type, which= I have no visibility into, since they are unknown. Consequently, I just h= ave to inherit the parents discriminants as-is, and none of the functionali= ty of W can depend on them. If, however, there was the ability to have a k= nown_formal_part on the formal derived type, I could at least do this in si= tuations where the actuals (Ax and Ay) had consistent numbers/types of disc= riminants, e.g. "T is a type extended from A with one Integer discriminant = 'D'", and so W could extend T by constraining D. Am I understanding all this correctly? Or are there perhaps other ways of d= oing this I am overlooking? I admittedly just starting to delve into Ada's= whole 'mix-in' approach, so please set me straight if i'm trying to put a = round peg into a square hole. Thank you again for your responses. -sb