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,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!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ranges and (non)static constraints Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1pqs0gcno5o2t.1195tm9yap28b.dlg@40tude.net> Date: Fri, 17 Nov 2006 15:57:53 +0100 Message-ID: <160ziiyah2n7g.5k340gtji747.dlg@40tude.net> NNTP-Posting-Date: 17 Nov 2006 15:57:53 CET NNTP-Posting-Host: 41564c90.newsspool2.arcor-online.net X-Trace: DXC=QQH[UX2D16Ak:C4l9A;OcOA9EHlD;3YcB4Fo<]lROoRAFl8W>\BH3YBhk23ATak28IDNcfSJ;bb[EFCTGGVUmh?DN\HXHJ4e80N[cNbUfJ>>A@ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7528 Date: 2006-11-17T15:57:53+01:00 List-Id: On Fri, 17 Nov 2006 11:37:14 +0100, Jean-Pierre Rosen wrote: > 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). Actually it is not the machine which cannot, but the compiler. Why should I care if an integer would fit a machine word? >> 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. 3) I don't want to mention any constraint now, but delegate it to the user. Generics is the only option for this now. > 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. Yes, I definitely agree with this rule. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de