comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: syntaxic exploration
Date: Sun, 24 Dec 2017 15:32:57 +0200
Date: 2017-12-24T15:32:57+02:00	[thread overview]
Message-ID: <fa9ok9Fq58lU1@mid.individual.net> (raw)
In-Reply-To: <p1lvu2$ve9$1@dont-email.me>

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
       .      @       .


  parent reply	other threads:[~2017-12-24 13:32 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 17:28 syntaxic exploration Mehdi Saada
2017-12-20 17:32 ` Mehdi Saada
2017-12-20 20:08   ` Niklas Holsti
2017-12-20 22:18     ` Mehdi Saada
2017-12-20 22:45       ` Mehdi Saada
2017-12-21  7:24         ` Randy Brukardt
2017-12-21  7:44           ` Niklas Holsti
2017-12-21  7:21   ` Randy Brukardt
2017-12-21 16:24     ` Jeffrey R. Carter
2017-12-22  5:01       ` Robert Eachus
2017-12-22 21:15         ` Simon Clubley
2017-12-22 22:11           ` Niklas Holsti
2017-12-22 22:51             ` Dmitry A. Kazakov
2017-12-23  7:15               ` Niklas Holsti
2017-12-23 16:23             ` Jeffrey R. Carter
2017-12-24  3:37               ` Robert Eachus
2017-12-24 13:39                 ` Niklas Holsti
2017-12-24 13:32               ` Niklas Holsti [this message]
2017-12-25 13:40                 ` Jeffrey R. Carter
2017-12-25 14:42                   ` Mehdi Saada
2017-12-25 17:03                     ` Dmitry A. Kazakov
2017-12-25 18:27                     ` Niklas Holsti
2017-12-25 20:12                     ` Jacob Sparre Andersen
2017-12-20 20:05 ` Niklas Holsti
2017-12-20 22:48 ` Mehdi Saada
2017-12-20 23:39   ` Mehdi Saada
2017-12-21  0:35 ` Mehdi Saada
2017-12-21  7:18 ` Randy Brukardt
2017-12-21 19:23   ` G. B.
2017-12-21 23:46   ` bj.mooremr
2017-12-22 23:45     ` Randy Brukardt
2017-12-22 13:31 ` Mehdi Saada
2017-12-22 18:00   ` Mehdi Saada
2017-12-22 18:27   ` Niklas Holsti
2017-12-22 20:25     ` Mehdi Saada
2017-12-22 22:33       ` Niklas Holsti
2017-12-23  1:47 ` Mehdi Saada
2017-12-23  7:17   ` Niklas Holsti
2017-12-23 11:23     ` Mehdi Saada
2017-12-23 11:39       ` Mehdi Saada
2017-12-23 12:09         ` Niklas Holsti
2017-12-23 12:12 ` Mehdi Saada
2017-12-23 12:16   ` Mehdi Saada
2017-12-23 13:04     ` Niklas Holsti
2017-12-23 14:02       ` Mehdi Saada
2017-12-23 14:46         ` Mehdi Saada
2017-12-23 15:03           ` Mehdi Saada
2017-12-23 22:11             ` Niklas Holsti
2017-12-24  0:55               ` Mehdi Saada
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox