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!news3.google.com!news.glorb.com!proxad.net!proxad.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Ranges and (non)static constraints Date: Fri, 17 Nov 2006 11:37:14 +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 1163761264 25370 195.25.228.57 (17 Nov 2006 11:01:04 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Fri, 17 Nov 2006 11:01:04 +0000 (UTC) User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:7522 Date: 2006-11-17T11:37:14+01:00 List-Id: Dmitry A. Kazakov a �crit : > [;;;] > I almost agree with this. However, unfortunately Ada does not require > legality of > > type T range 1..N; > > for any N, as it IMO should [*]. So the argument about portability becomes > a bit shaky. In fact it is only more portable than the second. However, the > second is definitely tasteless. This is legal for any N less than System.Max_Int (and illegal otherwise). It is therefore portable on any machine which is capable of supporting it - and illegal otherwise. If your machine cannot support what you ask for, you'd better discover it at compile time! (I'm sure you agree with this). > Well, this is nice in theory, which I strongly support. But this theory > applies only to application software, where Absolute_Max_Expectable_Value > is determinable from the problem space. > > When developing portable libraries, and Ada is one of the best choices > there, isn't it? Then the upper bound often becomes indeterminable. So > people are forced to use [new] Integer. ARM does this as well by defining > the type String based on Integer. Only in generics we have a choice to say: > > type T is range <>; > > This shouldn't be so. It is IMO a language defect. > Actually, you have two (three) choices for libraries: 1) You want the maximum possible range. Declare a new type based on System.Max_Int. 2) You want a "reasonable" type, given the capabilities of the machine. Either derive from Integer, or use Integer directly (not a bad choice for vector or matrix indices for example). That's what String did. But in that case, there is no reason to put an additional range constraint. What I was objecting to is putting a range on a derivation from Integer. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr