comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Ranges and (non)static constraints
Date: Fri, 17 Nov 2006 11:37:14 +0100
Date: 2006-11-17T11:37:14+01:00	[thread overview]
Message-ID: <tc3kje.tmr.ln@hunter.axlog.fr> (raw)
In-Reply-To: <g2go52hf14qn.16tb2xiy7ilrf.dlg@40tude.net>

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



  parent reply	other threads:[~2006-11-17 10:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-16 11:02 Ranges and (non)static constraints Maciej Sobczak
2006-11-16 12:23 ` Martin Krischik
2006-11-16 13:23   ` Maciej Sobczak
2006-11-16 19:01     ` Jeffrey R. Carter
2006-11-18  0:02   ` Robert A Duff
2006-11-16 13:13 ` Dmitry A. Kazakov
2006-11-16 17:18   ` Jean-Pierre Rosen
2006-11-17  9:08     ` Dmitry A. Kazakov
2006-11-17 10:30       ` Stuart
2006-11-17 10:37       ` Jean-Pierre Rosen [this message]
2006-11-17 14:57         ` Dmitry A. Kazakov
2006-11-17 16:04           ` Jean-Pierre Rosen
2006-11-18  9:51             ` Dmitry A. Kazakov
2006-11-18 14:17             ` Stephen Leake
2006-11-17 20:05           ` Jeffrey R. Carter
2006-11-17 23:58             ` Robert A Duff
2006-11-18  9:47               ` Dmitry A. Kazakov
2006-11-19  2:27               ` Jeffrey R. Carter
2006-11-19 12:13                 ` Björn Persson
2006-11-19 22:51                 ` Robert A Duff
2006-11-20  3:51                   ` Jeffrey R. Carter
2006-11-21 21:02                     ` Robert A Duff
2006-11-20 17:35                   ` Adam Beneschan
2006-11-17 15:45         ` Maciej Sobczak
2006-11-17 16:45           ` Jean-Pierre Rosen
2006-11-17 10:39       ` AW: " Grein, Christoph (Fa. ESG)
2006-11-17 11:20         ` Dmitry A. Kazakov
2006-11-17 13:30           ` Stuart
2006-11-17 15:07             ` Dmitry A. Kazakov
2006-11-17 16:47               ` Jean-Pierre Rosen
2006-11-20 14:08               ` Stuart
2006-11-20 14:12                 ` Stuart
2006-11-20 15:48                   ` Dmitry A. Kazakov
2006-11-16 18:56   ` Jeffrey R. Carter
2006-11-16 20:00 ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox