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!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: 'raise' in aspects? Date: Thu, 23 Oct 2014 17:42:08 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <85siilc88t.fsf@stephe-leake.org> <85h9ywasfq.fsf@stephe-leake.org> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1414104128 16736 69.95.181.76 (23 Oct 2014 22:42:08 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 23 Oct 2014 22:42:08 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:22691 Date: 2014-10-23T17:42:08-05:00 List-Id: "Stephen Leake" wrote in message news:85h9ywasfq.fsf@stephe-leake.org... > Stephen Leake 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.