comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: 'raise' in aspects?
Date: Thu, 23 Oct 2014 17:42:08 -0500
Date: 2014-10-23T17:42:08-05:00	[thread overview]
Message-ID: <m2c080$gb0$1@loke.gir.dk> (raw)
In-Reply-To: 85h9ywasfq.fsf@stephe-leake.org

"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:85h9ywasfq.fsf@stephe-leake.org...
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> The Ada mode 5.0 parser rejects this code:
>>
>>    subtype Integer_String is String
>>      with Dynamic_Predicate => Integer'Value (Integer_String) in Integer
>>             or else raise Constraint_Error with "not an integer string";
>>
>> It complains that 'raise' is not allowed here.
>>
>> ALRM Annex P says the syntax for an aspect is:
>>
>>      aspect_specification ::=
>>         with aspect_mark [=> aspect_definition] {,
>>                 aspect_mark [=> aspect_definition] }
>>
>>      aspect_mark ::= aspect_identifier['Class]
>>
>>      aspect_definition ::= name | expression | identifier
>>
>>
>> And you can't put 'raise' in an expression, which is why the Ada mode
>> parser rejects it.
>>
>> But GNAT GPL 2014 accepts it.
>>
>> Can anyone point me to RM language that allows 'raise' in aspects?
>
> For the record:
>
> ai12-0022 adds "raise_expression" to the "relation" syntax. It's a
> binding interpretation on Ada 2012
>
> http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0022-1.txt?rev=1.13

Right, "raise_expression" can be used in any expression, not just aspects. 
Indeed, we immediately noticed that it fixed one long-standing problem in 
Ada (the need to have a return statement in every function). You can write
    raise Program_Error with "Not yet implemented";
in any function (since a raise expression matches any type), and you don't 
have to dream up a useless dummy return value to do so.

                                     Randy.



  reply	other threads:[~2014-10-23 22:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-18 22:40 'raise' in aspects? Stephen Leake
2014-10-22  5:42 ` Simon Wright
2014-10-22  5:45   ` Simon Wright
2014-10-22 18:08 ` Stephen Leake
2014-10-23 22:42   ` Randy Brukardt [this message]
2014-10-24  3:22     ` Shark8
2014-10-24  7:20     ` Simon Wright
2014-10-26  5:16       ` Randy Brukardt
replies disabled

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