comp.lang.ada
 help / color / mirror / Atom feed
From: "Stuart" <stuart@0.0>
Subject: Re: Ranges and (non)static constraints
Date: Fri, 17 Nov 2006 10:30:19 -0000
Date: 2006-11-17T10:30:19+00:00	[thread overview]
Message-ID: <455d8c3c$1_1@glkas0286.greenlnk.net> (raw)
In-Reply-To: g2go52hf14qn.16tb2xiy7ilrf.dlg@40tude.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:g2go52hf14qn.16tb2xiy7ilrf.dlg@40tude.net...

> On Thu, 16 Nov 2006 18:18:47 +0100, Jean-Pierre Rosen wrote:
>> 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?
...
>> 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;

> 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:

Surely there is System.Max_Int!
   [ARM 13.7 (23)] The largest (most positive) value allowed for the 
expression
  of a signed_integer_type_definition.

So you would have:
   type Biggest_T is range 1..System.Max_Int;
  subtype T is Biggest_T range 1..N;

-- 
Stuart 





  reply	other threads:[~2006-11-17 10:30 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 [this message]
2006-11-17 10:37       ` Jean-Pierre Rosen
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