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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9b7d3a51d0d8b6ee X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!postnews.google.com!v39g2000pro.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Extending discriminant types Date: Thu, 20 Nov 2008 08:11:53 -0800 (PST) Organization: http://groups.google.com Message-ID: <4498e535-7c24-4563-bbe8-6533a916a1c2@v39g2000pro.googlegroups.com> References: <20081115101632.5f98c596@cube.tz.axivion.com> <26f0cb8c-eb3e-4c0d-85d1-f45e2c1ba4c6@j38g2000yqa.googlegroups.com> <6fcfeaa4-e70c-4f58-aa69-0e5aac145000@x8g2000yqk.googlegroups.com> <49254dd7$0$30232$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1227197513 25532 127.0.0.1 (20 Nov 2008 16:11:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 20 Nov 2008 16:11:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v39g2000pro.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2715 Date: 2008-11-20T08:11:53-08:00 List-Id: On Nov 20, 3:45 am, Georg Bauhaus wrote: > Ludovic Brenta schrieb: > > > On Nov 20, 9:30 am, christoph.gr...@eurocopter.com wrote: > >> On 20 Nov., 08:21, a...@anon.org (anon) wrote: > > >>> Since, the orginal post suggest that the poster was using GNAT Ada 95 > >>> compiler. Because the poster states that he can compiler the code. So, > >>> I used Gnat 3.15p using Ada 95 specs. > > > One can also try GNAT GPL Edition 2008 or GCC 4.3 (or even 4.4) and > > pass it the -gnat95 option which is documented in the Secret GNAT > > User's Guide. > > GNAT has -gnat83 as well, but rejects, too, because there are > neither tagged nor abstract types in Ada 83. > > Just out of curiosity, given > > type T is tagged ...; > type D is new T with ...; > type E is new D with ...; > > what would E'Base be? Type declarations define both "types" and "subtypes". Only subtypes have constraints; types don't. Subtypes and types are different kinds of entities---a subtype isn't a special case of a type. So the declaration of T defines both a type T, and a "first subtype" T. The declaration of D defines a derived type D whose parent type is the *type* T; and it also defines a "first subtype" D of the *type* D.. Similarly for E: it defines a type E whose parent type is D, and a first subtype E of the type E. If E'Base were defined the same way it's defined for scalars, then it would refer to an unconstrained subtype of the *type* E. As Bob pointed out, that would be essentially the same as the "first subtype" E, since there are no discriminants on that type. But one could imagine something like type U (Disc : Integer) is record ... end record; type F is new U(7); type G is new F; The *types* U, F, and G aren't constrained, so if G'Base were allowed, it would be an unconstrained subtype of G---i.e. Disc could be anything. I don't really know why E'Base or G'Base isn't allowed. As far as I can tell, it wouldn't cause any semantic problems to allow it, but it might prevent some useful optimizations in variant record cases. But I'm just guessing. > Assuming that D is privately tagged, would E'Base > have different effects depending on whether [D's] tag > is visible or not? [corrected] I don't think this question makes sense unless you mistakenly think that 'Base has something to do with the parent type of a type. But as we've pointed out, it doesn't. By the way, I believe there was a proposal for a 'Parent attribute or something like that to refer to a derived type's parent (or its first subtype), but it didn't make it into the language. -- Adam