Version 1.2 of ai12s/ai12-0105-1.txt

Unformatted version of ai12s/ai12-0105-1.txt version 1.2
Other versions for file ai12s/ai12-0105-1.txt

!standard 13.1.1(18/3)          14-07-23 AI05-0105-1/02
!class binding interpretation 14-05-13
!status Corrigendum 2015 14-07-23
!status ARG Approved 78-0-0 14-06-28
!status work item 14-05-13
!status received 14-04-25
!priority Low
!difficulty Easy
!qualifier Omission
!subject Pre is not allowed on any subprogram completion
!summary
A language-defined aspect (like Pre) is not allowed on any subprogram completion.
!question
13.1.1(18/3) says "A language-defined aspect shall not be specified in an aspect_specification given on a subprogram_body or subprogram_body_stub that is a completion of another declaration."
This is intended to prevent hiding aspects like Pre on a body, as they are intended to be known to callers.
However, an expression_function that is a completion is not a subprogram_body, so the above doesn't apply to it. Similarly for a null_procedure that is a completion. The rule should apply those as well, right? (Yes.)
!recommendation
(See Summary.)
!wording
Modify 13.1.1(18/3):
A language-defined aspect shall not be specified in an aspect_specification given on a [subprogram_body or subprogram_body_stub that is a] completion of {a subprogram or generic subprogram}[another declaration].
!discussion
While an expression_function that is a completion is not a subprogram_body (syntax font), it is a body (regular font) and it surely is a subprogram (regular font). So we redo the wording to use semantic terms. The alternative of listing each of the kinds of declaration would get wordy and would potentially pose a future maintenance hazard (should any additional kinds of body get defined).
!corrigendum 13.1.1(18/3)
Replace the paragraph:
A language-defined aspect shall not be specified in an aspect_specification given on a subprogram_body or subprogram_body_stub that is a completion of another declaration.
by:
A language-defined aspect shall not be specified in an aspect_specification given on a completion of a subprogram or generic subprogram.
!ASIS
No ASIS effect.
!ACATS test
Any ACATS B-Test could be written to check that this error is detected on expression_functions and null_procedures.
!appendix

From: Randy Brukardt
Sent: Friday, April 25, 2014 11:57 PM

13.1.1(18/3) says "A language-defined aspect shall not be specified in an
aspect_specification given on a subprogram_body or subprogram_body_stub that
is a completion of another declaration."

This is intended to prevent something like:

   package PK is
     procedure Pr (...);
   end PK;

   package body PK is
     procedure Pr (...) with Pre => ...;
   end PK;

since Pre is intended to be known to the caller, and stuff hidden in bodies
should be irrelevant to the caller.

However, a null_procedure declaration is not a subprogram_body, so:

   package PK2 is
     procedure Pr (...);
   end PK2;

   package body PK2 is
     procedure Pr (...) is null with Pre => ...;
   end PK2;

is not covered by 13.1.1(18/3), and presumably its legal.

Similarly for expression functions:

   package PK3 is
     function Fn (...) return ...;
   end PK3;

   package body PK3 is
     function Fn (...) return ... is (...) with Pre => ...;
   end PK3;

We can fix this by replacing "subprogram_body" (syntax font) with "subprogram
body" (normal font). That's because an expression function that is a completion
is a body (normal font), but not a body (syntax font) or a subprogram_body
(syntax font). Similarly for a null procedure. Whatever the rule is, we
certainly want it to work the same for any kind of subprogram body!

Of course, we want body (normal font) and not body (bold font), because the
latter just represents a reserved word. "body" is such fun, since it has three
different meanings depending upon font. (My favorite mis-example from the Ada
Standard.) That's the sort of thing that separates out those C hackers from us
brilliant Ada engineers. ;-)

****************************************************************

From: Erhard Ploedereder
Sent: Saturday, April 26, 2014  2:42 PM

> 13.1.1(18/3) says "A language-defined aspect shall not be specified in 
> an aspect_specification given on a subprogram_body or 
> subprogram_body_stub that is a completion of another declaration."

Make this read:
"A language-defined aspect shall not be specified in an aspect_specification
given on a subprogram_body, subprogram_body_stub or null_procedure_declaration
that is a completion of another declaration."

My reasoning: adding a third syntactic category fixes the problem as well;
otherwise, i.e., in Rand'y's original solution, you have to mix syntactic and
semantic terms, since the stub does not qualify as semantic subprogram body.

****************************************************************

From: Randy Brukardt
Sent: Sunday, April 27, 2014  8:26 PM

A couple of thoughts:

(1) We'd have to include expression_function_declaration in the above as well.
(2) It'd be somewhat inconsistent with other rules where we use semantic body
(for instance 13.14(3/3)). Explicitly listing the different kinds of body would
somewhat increase the maintenance hazard for future versions of the standard.

Neither of these is show-stopping, but I think if we were going to make a
change from my original proposal, I would suggest going to all semantic:

"A language-defined aspect shall not be specified in an aspect_specification
given on a subprogram body or stub that is a completion of another
declaration."

which is less likely to cause future problems and it's easier to read as well.

****************************************************************

From: Erhard Ploedereder
Sent: Monday, April 28, 2014  4:29 AM

And it reads better. I agree.

****************************************************************

From: Tullio Vardanega
Sent: Monday, April 28, 2014  4:41 AM

I like that formulation better, too.

****************************************************************



Questions? Ask the ACAA Technical Agent