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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: syntaxic exploration Date: Sun, 24 Dec 2017 15:32:57 +0200 Organization: Tidorum Ltd Message-ID: References: <0d33e631-e63d-4346-ac95-5eec72127f4f@googlegroups.com> <0fa75dd5-599b-4a38-a5d4-3151bbe5172f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net qMSsGbpDp503YmZUH7ke9wf/DAa3KR7D+2476rp1bPxCidsFov Cancel-Lock: sha1:6qvgcflnZpdnNfMFyr3E0v3kIuA= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader02.eternal-september.org comp.lang.ada:49622 Date: 2017-12-24T15:32:57+02:00 List-Id: On 17-12-23 18:23 , Jeffrey R. Carter wrote: > On 12/22/2017 11:11 PM, Niklas Holsti wrote: >> >> I think the aggregate form (null array) was suggested some time ago, >> in analogy with the existing (null record). It looks good to me, but >> as I remember, there was some objection. One problem is that if the >> index type has exactly one value, then a null array with that index >> type cannot exist (because then A'First = A'Last for any such array A). > > Actually, a null array of such a type can exist if it's a string type, > because you can use the string literal "" for such types. AIUI, 'Last is > undefined for such a value. RM 4.2(9) says "for a null string literal, the upper bound is the predecessor of the lower bound". I would understand this to mean applying 'Pred to the lower bound, which will raise Constraint_Error if the type has only one value. If I try this with GNAT: type One_T is (Unique); type Str_T is array (One_T range <>) of Character; S : constant Str_T := ""; I get compilation errors: nullstr.adb:11:26: null string literal not allowed for type "Str_T" defined at line 9 nullstr.adb:11:26: static expression fails Constraint_Check where line 11 is the one with the "" literal. So one can try to make a null array of this type with "", but it will fail. > Allowing (null array) for non-string array > types with an index type with a single value would presumably work the > same. I agree, it should also raise Constraint_Error. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .