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: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!b9g2000yqm.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: unsigned type Date: Tue, 30 Jun 2009 18:39:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246412372 11524 127.0.0.1 (1 Jul 2009 01:39:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 1 Jul 2009 01:39:32 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b9g2000yqm.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6778 Date: 2009-06-30T18:39:31-07:00 List-Id: On Jun 30, 4:48=A0pm, a...@anon.org (anon) wrote: > Read RM 3.5 =A0( 4 ) > > Is "A ( 0 .. 0 )" an example of null range. =A0By the definition in RM 3.= 5 > ( 4 ), the Right side range (index) must be less than the Left side, so > "A ( 0.. 0 )" is not a valid null range statement. So, this statement > should generate a compiler or runtime error, because either range is not > a subset of the range for Strings. OK, I think I've finally figured out why we're having this confusing argument. It goes way back to this post of yours: >> For Strings: >> -- 'A' is a zero length string, A'Last =3D 0, = and >> -- put_line ( A ( A'First .. A'Last ) ) ; >> -- does not raise an Constraint_Error even tho= ugh in >> -- this case it translate to: >> -- put_line ( A ( 0 .. 0 ) ) ; >> A : String :=3D "" ; It does not translate to A (0..0); it translates to A (1..0). If A is declared as in your example above, A'First will be 1 and A'Last will be 0. Try it (try declaring A like that and outputting A'First and A'Last). It looks like everyone else missed this original error of yours, which has apparently led to some confusion. In this case, A'First..A'Last, which is 1..0, is compatible with the subtype because it's a null range, and null ranges are compatible with the subtype even when the range bounds don't actually belong to the subtype. 0..0 is not compatible with the subtype, but you cannot declare a string with that index range unless you try to do it explicitly: A : String (0..0); and then you *will* get a Constraint_Error. So your later assertion that follows: >> Since you can have zero length string , the index is Natual instead of P= ositive, >> because zero is in Natural but is not define in Positive. Even though th= e >> Standard package define String index as a Positive type. (GNAT) is wrong. The index range is Positive, but null ranges don't have to meet that constraint. They don't have to be Natural, either. This is legal and will not raise an exception at runtime: B : String (-9 .. -10) :=3D ""; Hope this clears everything up. -- Adam