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,4ff929aa5c2b2834 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!aotearoa.belnet.be!news.belnet.be!skynet.be!grolier!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Ranges and (non)static constraints Date: Thu, 16 Nov 2006 18:18:47 +0100 Organization: Adalog Message-ID: References: <1pqs0gcno5o2t.1195tm9yap28b.dlg@40tude.net> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1163700064 25285 195.25.228.57 (16 Nov 2006 18:01:04 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Thu, 16 Nov 2006 18:01:04 +0000 (UTC) User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) In-Reply-To: <1pqs0gcno5o2t.1195tm9yap28b.dlg@40tude.net> Xref: g2news2.google.com comp.lang.ada:7508 Date: 2006-11-16T18:18:47+01:00 List-Id: Dmitry A. Kazakov a �crit : > On Thu, 16 Nov 2006 12:02:15 +0100, Maciej Sobczak wrote: > >> type T is range 1 .. N; >> type U is new Integer range 1 .. M; >> >> N must be static, but M does not have to. >> Why and what is the real difference between T and U? > > Informally, the second is an abbreviation for: > > type is new Integer; > subtype U is range 1..M; > > so "range" refers to a subtype. On the contrary, in the first, "range" > refers a type. So the difference. > > Is it real? I don't think so. Sorry, but there is a huge difference. With U, the range cannot be outside the range of Integer, under penalty of Constraint_Error. T is valid as long as the compiler offers a big enough integer type, and if it doesn't, it won't compile. Actually, the second form should never be used: you are relying on Integer, a non-portable type that plays absolutely (or almost) no special role in Ada. Why derive from Integer, rather than from Long_Integer, or anything else? If you want dynamic bounds, remember that anything "dynamic" has to have an upper limit at some point. It is thus better to write: type Biggest_T is range 1 .. Absolute_Max_Expectable_Value; subtype T is Biggest_T range 1 .. N; -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr