Version 1.1 of acs/ac-00016.txt

Unformatted version of acs/ac-00016.txt version 1.1
Other versions for file acs/ac-00016.txt

!standard 6.3.2(3)          01-10-16 AC95-00016/01
!class uninteresting 01-10-16
!status received 01-10-10
!subject pragma Read_Only
!summary
!appendix

From: V. Santhanam (Boeing)
Sent: Wednesday, October 10, 2001 9:12 AM

Issue:

In Ada, it is awkward to create a variable in a package for read/write use
internally but read-only use by clients. To achieve this, one would have to
declare the variable either in the private part of the package spec or in
the body, and provide a visible function to read the variable.

Solution:

Provide a Read_Only pragma which can be applied to variables in the visible
part of a package so that they are treated as constants by the clients of
the package. Example:

	Error_Count : Natural := 0;
	pragma Read_Only (Error_Count);

The read-only restriction is not applicable the declaring package itself.

Reasoning:

The reader function approach incurs a significant run-time penalty. I know
of at least one program in which a decision was made to declare all such
variables in the visible part of the package, exposing them to potential
modifications by clients, in order to avoid the function call penalty.
Inlining the function call was not an option for certification reasons. The
proposed solution will avoid the run-time penalty without sacrificing
safety.

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

From: Randy Brukardt
Sent: Tuesday, October 16, 2001  7:12 PM

> The reader function approach incurs a significant run-time penalty.

It shouldn't have any runtime penalty, if combined with a pragma Inline. Why
doesn't that solve your problem without introducing any new language features?
(If your vendor doesn't Inline these properly, either pressure or change the
vendor! This is the sort of thing that Inline was designed to handle).

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

Questions? Ask the ACAA Technical Agent