Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #221: The mainframe needs to rest. It's getting old, you know.


comp / comp.lang.ada / Re: Raise expressions from AARM.

SubjectAuthor
* Raise expressions from AARM.Blady
+* Re: Raise expressions from AARM.Jeffrey R.Carter
|`- Re: Raise expressions from AARM.Blady
`* Re: Raise expressions from AARM.Niklas Holsti
 `* Re: Raise expressions from AARM.Blady
  `- Re: Raise expressions from AARM.Niklas Holsti

1
Subject: Raise expressions from AARM.
From: Blady
Newsgroups: comp.lang.ada
Organization: A noiseless patient Spider
Date: Sat, 24 Feb 2024 09:50 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Raise expressions from AARM.
Date: Sat, 24 Feb 2024 10:50:31 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <urce58$14j88$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 24 Feb 2024 09:50:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0797415f6828158c9da18fbcfb46b142";
logging-data="1199368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Qm9e/BlxJUzA7plpWLiCA"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vIBHheHg6OUcjVI/EDtZK8scNoo=
Content-Language: fr, en-US
View all headers

Hello,

AARM Ada 2022 section 11.3 presents some uses of raise expressions
including this one:
(http://www.ada-auth.org/standards/22aarm/html/AA-11-3.html)

2.a.10/4 ...

B : Some_Array := (1, 2, 3, others => raise
Not_Valid_Error);

What could be the use cases?

My guess: whatever the size of Some_Array (greater than 3), B is
elaborated but raises Not_Valid_Error when accessing component beyond
position 3:

type Some_Array is array (Positive range 1..10) of Natural;
....
B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
....
begin
X := B (2); -- OK
X := B (6); -- raises Not_Valid_Error
end;

Is it correct?

NB: GNAT 13.2 issues a compilation error:
>>> error: "others" choice not allowed here
see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113862

Thanks, Pascal.

Subject: Re: Raise expressions from AARM.
From: Jeffrey R.Carter
Newsgroups: comp.lang.ada
Organization: A noiseless patient Spider
Date: Sat, 24 Feb 2024 10:39 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Raise expressions from AARM.
Date: Sat, 24 Feb 2024 11:39:08 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <urch0c$14nrc$1@dont-email.me>
References: <urce58$14j88$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 24 Feb 2024 10:39:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a300bf9e1793e69cc0a30f9e974c200d";
logging-data="1204076"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QwhVeTWgpPvbHgl90LmE4hBQQp5ZVWY8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:yoxPbFUIZ9BOO54MQRCWj1RD/i8=
Content-Language: en-US
In-Reply-To: <urce58$14j88$1@dont-email.me>
View all headers

On 2024-02-24 10:50, Blady wrote:
>
> My guess: whatever the size of Some_Array (greater than 3), B is elaborated but
> raises Not_Valid_Error when accessing component beyond position 3:
>
> type Some_Array is array (Positive range 1..10) of Natural;
> ...
> B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
> ...
> begin
> X := B (2); -- OK
> X := B (6); -- raises Not_Valid_Error
> end;
>
> Is it correct?

No. This will raise the exception upon the elaboration of B.

The only use of this that I can imagine is if the length of Some_Array is 3.
Then the others choice is null, so the raise expression is never evaluated. But
if someone changes the definition of Some_Array to be longer, then the exception
will be raised.

> NB: GNAT 13.2 issues a compilation error:
>         >>> error: "others" choice not allowed here
> see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113862

The example in the error report has Some_Array unconstrained, in which case an
others choice is not allowed. With the constrained definition given above, the
aggregate is valid.

--
Jeff Carter
"Gentlemen, you can't fight in here. This is the War Room!"
Dr. Strangelove
30

Subject: Re: Raise expressions from AARM.
From: Niklas Holsti
Newsgroups: comp.lang.ada
Organization: Tidorum Ltd
Date: Sat, 24 Feb 2024 10:39 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.building-m.net!news.quux.org!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Raise expressions from AARM.
Date: Sat, 24 Feb 2024 12:39:43 +0200
Organization: Tidorum Ltd
Lines: 68
Message-ID: <l3tvbfF913vU1@mid.individual.net>
References: <urce58$14j88$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net zjr83PLGCI9K+lwugYoFNAhKJLETs/c5HQpOIL1Z6QuY1hzm7r
Cancel-Lock: sha1:m7DXgCl9XEireedzjqEJn3ERapA= sha256:LXlGmp+ytKfpP6bqbilJDfLTlDJTROT4xI1sTI+PXvM=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <urce58$14j88$1@dont-email.me>
View all headers

On 2024-02-24 11:50, Blady wrote:
> Hello,
>
> AARM Ada 2022 section 11.3 presents some uses of raise expressions
> including this one:
> (http://www.ada-auth.org/standards/22aarm/html/AA-11-3.html)
>
> 2.a.10/4        ...
>
>                 B : Some_Array := (1, 2, 3, others => raise
> Not_Valid_Error);
>
> What could be the use cases?

The point of these examples (which are only in the discussion
annotation, not in the normative standard) is to discuss what is
syntactically legal and why. The examples need not make practical sense.

> My guess: whatever the size of Some_Array (greater than 3), B is
> elaborated but raises Not_Valid_Error when accessing component beyond
> position 3:

No. A raise-expression is not a value that can be stored in an array or
passed around; its evaluation raises an exception /instead/ of yielding
a value.

In this example, if the evaluation of the array aggregate that
initializes B evaluates the expression supplied for the "others" choice,
this evaluation will raise Not_Valid_Error and disrupt the
initialization of B.

It is not clear to me if the RM requires the evaluation of the "others"
expression if there are no "other" indices. Experimenting with GNAT
(Community 2019) shows that if the Some_Array type has 'Length = 3, the
exception is not raised (so the "others" value is not evaluated), while
if the 'Length is greater than 3 the exception is raised.

> type Some_Array is array (Positive range 1..10) of Natural;
> ...
> B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);

That should raise Not_Valid_Error during the initialization of B.

> ...
> begin
> X := B (2); -- OK
> X := B (6); -- raises Not_Valid_Error
> end;
>
> Is it correct?

No.

>
> NB: GNAT 13.2 issues a compilation error:
>         >>> error: "others" choice not allowed here
> see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113862

Interesting. GNAT Community 2019 accepted it.

Subject: Re: Raise expressions from AARM.
From: Blady
Newsgroups: comp.lang.ada
Organization: A noiseless patient Spider
Date: Sun, 25 Feb 2024 11:09 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Re: Raise expressions from AARM.
Date: Sun, 25 Feb 2024 12:09:08 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <urf74l$1qfpk$1@dont-email.me>
References: <urce58$14j88$1@dont-email.me> <urch0c$14nrc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Feb 2024 11:09:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4b24abc7ed527ba7b68b6767d8d8ed52";
logging-data="1916724"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hTjnu0m2PyjGk4+CmggWS"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:k13ioVHnwMg1xYgo8WYRaduk+J8=
Content-Language: fr, en-US
In-Reply-To: <urch0c$14nrc$1@dont-email.me>
View all headers

Le 24/02/2024 à 11:39, Jeffrey R.Carter a écrit :
> On 2024-02-24 10:50, Blady wrote:
>>
>> My guess: whatever the size of Some_Array (greater than 3), B is
>> elaborated but raises Not_Valid_Error when accessing component beyond
>> position 3:
>>
>> type Some_Array is array (Positive range 1..10) of Natural;
>> ...
>> B : Some_Array := (1, 2, 3, others => raise Not_Valid_Error);
>> ...
>> begin
>> X := B (2); -- OK
>> X := B (6); -- raises Not_Valid_Error
>> end;
>>
>> Is it correct?
>
> No. This will raise the exception upon the elaboration of B.
>
> The only use of this that I can imagine is if the length of Some_Array
> is 3. Then the others choice is null, so the raise expression is never
> evaluated. But if someone changes the definition of Some_Array to be
> longer, then the exception will be raised.

If I understand well, no compiler error nor warning at compilation time
but Not_Valid_Error raised at run time elaboration.
To be compared with:
B1 : Some_Array := (1, 2, 3);
No compiler error, one compiler warning "Constraint_Error will be raised
at run time" and Constraint_Error range check failed raised at run time
elaboration.

>> NB: GNAT 13.2 issues a compilation error:
>>          >>> error: "others" choice not allowed here
>> see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113862
>
> The example in the error report has Some_Array unconstrained, in which
> case an others choice is not allowed. With the constrained definition
> given above, the aggregate is valid.

Thanks to point out, I've corrected the GNAT report.

Pascal.

Subject: Re: Raise expressions from AARM.
From: Blady
Newsgroups: comp.lang.ada
Organization: A noiseless patient Spider
Date: Sun, 25 Feb 2024 11:23 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: p.p11@orange.fr (Blady)
Newsgroups: comp.lang.ada
Subject: Re: Raise expressions from AARM.
Date: Sun, 25 Feb 2024 12:23:48 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <urf805$1qfpk$2@dont-email.me>
References: <urce58$14j88$1@dont-email.me> <l3tvbfF913vU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Feb 2024 11:23:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4b24abc7ed527ba7b68b6767d8d8ed52";
logging-data="1916724"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vxl+nLRNb1uAJpUvfFETJ"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hYleSD1A1MaNazIzG3vj5AGqs2c=
Content-Language: fr, en-US
In-Reply-To: <l3tvbfF913vU1@mid.individual.net>
View all headers

Le 24/02/2024 à 11:39, Niklas Holsti a écrit :
> The point of these examples (which are only in the discussion
> annotation, not in the normative standard) is to discuss what is
> syntactically legal and why. The examples need not make practical sense.

Well, despite I knew that, I wanted to draw some use cases from them.
For instance:
A : A_Tagged := (Some_Tagged'(raise TBD_Error) with Comp => 'A');
It will raise TBD_Error if Some_Tagged is not a null record, good to
know, isn't it?

Pascal.

Subject: Re: Raise expressions from AARM.
From: Niklas Holsti
Newsgroups: comp.lang.ada
Organization: Tidorum Ltd
Date: Mon, 26 Feb 2024 20:01 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Raise expressions from AARM.
Date: Mon, 26 Feb 2024 22:01:23 +0200
Organization: Tidorum Ltd
Lines: 23
Message-ID: <l4490jF67e6U1@mid.individual.net>
References: <urce58$14j88$1@dont-email.me> <l3tvbfF913vU1@mid.individual.net>
<urf805$1qfpk$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net Bfxuc1SPmeN3g4kDe0UTNQIkh7m1R5InalsM8BZd/Q0YDPZaJJ
Cancel-Lock: sha1:cZqKD1wtrYL23BZ/eHXKWutZQdE= sha256:ntP7vPgSZDP4AdPzNZQwrtOvPy1APGnnxSues9Ks1D0=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <urf805$1qfpk$2@dont-email.me>
View all headers

On 2024-02-25 13:23, Blady wrote:
> Le 24/02/2024 à 11:39, Niklas Holsti a écrit :
>> The point of these examples (which are only in the discussion
>> annotation, not in the normative standard) is to discuss what is
>> syntactically legal and why. The examples need not make practical sense.
>
> Well, despite I knew that, I wanted to draw some use cases from them.
> For instance:
>   A : A_Tagged   := (Some_Tagged'(raise TBD_Error) with Comp => 'A');
> It will raise TBD_Error if Some_Tagged is not a null record, good to
> know, isn't it?

Hm, not raising the exception for a null record seems weird to me, and I
cannot deduce it from the RM. Moreover, for a plain qualified expression

Some_Tagged'(raise TBD_Error)

not in an extension aggregate GNAT raises the exception even if the type
is a null record. I suspect that not raising the exception for an
extension aggregate where the ancestor type is a null record is a bug in
GNAT.

1

rocksolid light 0.9.8
clearnet tor