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: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: unsigned type Reply-To: anon@anon.org (anon) References: <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: <8x73m.415010$4m1.171425@bgtnsc05-news.ops.worldnet.att.net> Date: Thu, 02 Jul 2009 19:04:36 GMT NNTP-Posting-Host: 12.65.42.163 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1246561476 12.65.42.163 (Thu, 02 Jul 2009 19:04:36 GMT) NNTP-Posting-Date: Thu, 02 Jul 2009 19:04:36 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:6808 Date: 2009-07-02T19:04:36+00:00 List-Id: Adam. RM 3.6.1 ( 17..18 ) proves your point about strings with subscripts of ( 1..0 ). But it kinds of flys in the face of RM 0 ( 29 ) [ see below ]. Since we must use the keyword "reverse" to transverse a loop index in deceasing order, it would seam logical that ( 1 .. 0 ) or S ( S'First .. ( S'First - 1 ) ) should be illegal for Strings because the 0 is not within the range of the predefined type Positive. But a String with length greater than 1 the we could use: S ( ( S'First + 1 ) .. S'First ) => S ( 2 ..1 ) would be legal because both index values are legal subscripts and these values could be all the way to S ( S'Last .. S'First ) to get a null array (String). Note : Around line 291 of RM 95 Text version RM 0. (29) 29 Execution of a program unit may encounter error situations in which normal program execution cannot continue. For example, an arithmetic computation may exceed the maximum allowed value of a number, or an attempt ^^^^^^^^^^^^^ may be made to access an array component by using an incorrect index value. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To deal with such error situations, the statements of a program unit can be textually followed by exception handlers that specify the actions to be taken when the error situation arises. Exceptions can be raised explicitly by a raise statement. In <273dedb7-8d68-42d2-8602-aa44c79f3708@b9g2000yqm.googlegroups.com>, Adam Beneschan writes: >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 >