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.1 required=5.0 tests=BAYES_00,FROM_NUMERIC_TLD, PP_MIME_FAKE_ASCII_TEXT 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!news3.google.com!news.glorb.com!news.kjsl.com!news-peer-lilac.gradwell.net!not-for-mail From: "Stuart" Newsgroups: comp.lang.ada References: <1pqs0gcno5o2t.1195tm9yap28b.dlg@40tude.net> Subject: Re: Ranges and (non)static constraints Date: Fri, 17 Nov 2006 10:30:19 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Message-ID: <455d8c3c$1_1@glkas0286.greenlnk.net> X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: 20.133.0.1 X-Trace: 1163759426 news.gradwell.net 625 dnews/20.133.0.1:22723 X-Complaints-To: news-abuse@gradwell.net Xref: g2news2.google.com comp.lang.ada:7520 Date: 2006-11-17T10:30:19+00:00 List-Id: "Dmitry A. Kazakov" 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