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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 25 Nov 2008 23:09:34 +0100 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Extending discriminant types References: <20081115101632.5f98c596@cube.tz.axivion.com> <20081122011825.5354d1c1@cube.tz.axivion.com> <4928ecad$0$32681$9b4e6d93@newsspool2.arcor-online.net> <648Wk.39330$_Y1.32087@bgtnsc05-news.ops.worldnet.att.net> <492a7d07$0$30236$9b4e6d93@newsspool1.arcor-online.net> <8e021577-260a-44e1-b765-4d81f6ba89df@33g2000yqm.googlegroups.com> <492be08b$0$32676$9b4e6d93@newsspool2.arcor-online.net> <0xZWk.396391$TT4.276049@attbi_s22> <71304b75-71bc-4691-b511-69882bdc0fc3@a12g2000pro.googlegroups.com> In-Reply-To: <71304b75-71bc-4691-b511-69882bdc0fc3@a12g2000pro.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <492c77a1$0$31347$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 25 Nov 2008 23:09:37 CET NNTP-Posting-Host: ced36a48.newsspool4.arcor-online.net X-Trace: DXC=7E^Inod14;H02Sh8E_NfIA4IUK Adam Beneschan wrote: > On Nov 25, 12:49 pm, "Jeffrey R. Carter" > wrote: >> Georg Bauhaus wrote: >> >>> generic >>> type N is (<>); >>> package U is >>> type T (Len: Integer) is private ; >>> type Count is new N range 0 .. N'Base'Last; -- 'BASE >> It's interesting that this compiles, since N is not an integer type. >> I suspect >> you've uncovered a compiler error. > > It also compiles if you remove the 'Base attribute. In fact, GNAT has let me instantiate this unit in Ada 2005 mode after I had commented the object declaration mentioning T'Base: WITH u; PACKAGE uu IS NEW u(N => INTEGER); But I'm lost here, is this really a bug? (I vaguely remember an issue with using integer types for enum I/O, see below.) Another compiler complains about N's range using inappropriate operands. The Ada 83 RM explains generic formal (<>) type in terms of their operations. And then, in 12.3 on Generic Instantiation, "For each occurrence, within the generic unit, of a name that denotes a given entity, the following list defines which entity is denoted by the corresponding occurrence within the instance. ... "4. For a name that denotes a generic formal type: The corresponding name denotes the subtype named by the associated generic actual parameter (the actual subtype). " (Which, I believe, is INTEGER in the instantiation above.) The following unit is accepted by two different compilers: with Ada.Text_IO; package I is new Ada.Text_IO.Enumeration_IO(Integer);