Version 1.2 of acs/ac-00168.txt

Unformatted version of acs/ac-00168.txt version 1.2
Other versions for file acs/ac-00168.txt

!standard 12.6(8.5/2)          08-10-06 AC95-00168/01
!class confirmation 08-10-06
!status received no action 08-10-06
!status received 08-06-17
!subject Null procedures with "out" parameters

From: Dmitry A. Kazakov
Date: Friday, September 12, 2008  2:21 AM

6.7 allows null procedures with out parameters:

   procedure Read (File : File_Type; Data : out Integer) is null;

This seems inconsistent with the implied meaning of "out" mode, as a return
parameter, similar to function return.


From: Adam Beneschan
Date: Wednesday, September 17, 2008  7:24 PM

The problem here is that although I can see how a procedure with "out"
parameters can be used in a similar way as a function, Ada already makes them
different in that while a function *must* return a result (and a function call
raises Program_Error if it returns without returning a result), a procedure with
OUT parameters doesn't have to set the OUT parameters.  Maybe you could argue
that it should be forced to, but it isn't.  So allowing a null procedure is at
least consistent, even if it's consistent with what is perhaps the wrong way of
doing things.

Offhand, though, I can't think of a case where I'd want to declare a procedure
with an OUT parameter and make it null (even for an interface type).  Can anyone
think of a legitimate use for this?  I'm considering making our compiler
generate a warning in this case on the theory that it's probably not what the
programmer intended.


From: Tucker Taft
Date: Wednesday, September 17, 2008  8:01 PM

I suppose it should probably remain legal, since a procedure whose body is
"begin null; end" is legal even if it has an OUT parameter, but I would also
agree that a compile-time warning might be in order, at least for OUT parameters
of a scalar type.  In fact AdaMagic warns about uninitialized OUT parameters at
the end of a normal procedure, so it would certainly want to warn about them for
a null procedure.

Furthermore a scalar OUT parameter is clearly uninitialized after a call on a
null procedure, and one could legitimately raise Program_Error on the assignment
implicit in the copy-back of this uninitialized value into the actual parameter,
since that's a bounded error.

Furthermore, if the subtype or the actual parameter is constrained, then one
could legitimately raise Constraint_Error, since an uninitialized value can be
presumed to be outside any specified range.


Questions? Ask the ACAA Technical Agent