CVS difference for ais/ai-00290.txt

Differences between 1.5 and version 1.6
Log of other versions for file ais/ai-00290.txt

--- ais/ai-00290.txt	2003/12/07 05:00:31	1.5
+++ ais/ai-00290.txt	2004/03/02 02:38:09	1.6
@@ -1,4 +1,4 @@
-!standard 10.2.1 (00)                              02-03-14  AI95-00290/00
+!standard 10.2.1 (00)                              04-02-29  AI95-00290/01
 !class amendment 02-03-13
 !status received 02-03-13
 !priority Medium
@@ -7,24 +7,89 @@
+A pragma Pure_Function may be used to declare that a particular
+function within an impure package is to be considered "pure"
+by the implementation. This means that a second call with identical
+inputs to a first call may be omitted, reusing the result of the first
+call instead of performing the second call.
+Making an entire package "pure" can be difficult, because
+it may necessarily depend on an impure package. Nevertheless,
+there are benefits to declaring that a given function may
+be treated as "pure" by the implementation, meaning that
+the outputs are a function of the inputs, without dependence
+on global variables, etc.
+(See wording.)
+Add a new section:
+  6.3.3 Pragma Pure_Function
+  A function may be declared *pure* to indicate that it has no significant
+  side-effects, and that the results it produces are a pure function of
+  its inputs, without any dependence on global variables.
+                   Syntax
+    The form of pragma Pure_Function, which is a program unit pragma
+    (see 10.1.5), is as follows:
+      pragma Pure_Function([Entity => ] function_local_name);
+                 Legality Rules
+  The pragma shall apply to one or more functions or generic functions.
+                 Implementation Permission
+  If a function is declared pure, then the implementation is permitted to
+  omit a call on the function if its results are not needed after the call.
+  In addition, the implementation may omit a call on such a function and
+  simply reuse the results produced by an earlier call on the same
+  function, provided that none of the parameters nor any object accessible
+  via access values from the parameters are of a limited type, and the
+  addresses and values of all by-reference actual parameters, the values of
+  all by-copy-in actual parameters, and the values of all objects
+  accessible via access values from the parameters, are the same as they
+  were at the earlier call. This permission applies even if the subprogram
+  produces other side effects when called.
+The existing ability to declare a library unit "pure" is useful, but is
+limiting given some of the stringent elaboration dependence requirements on
+such units. This pragma provides the benefits of declaring a function
+pure, without imposing such requirements. In fact, it imposes no
+requirements, though it is anticipated that implementations may provide
+warnings when the result of such a fuction clearly depends on the state of
+a global variable (for example).
+Pure functions are particularly useful for assertions (see AI-286).
+Although AI-286 does not require the use of pure functions in assertions,
+an implementation-defined assertion policy might impose such a requirement,
+or an implementation might warn about use of impure functions in
+Note that we do not permit implementations to *assume* a declared-pure
+function is truly "pure." Instead, we give permission to omit certain
+calls, even if in fact they are not "truly" redundant. This approach
+avoids the significant danger associated with allowing implementations to
+assume propositions to be true which in reality are not true. Assuming
+falsehoods can be used to prove essentially any considered proposition.
 !ACATS test
+An ACATS test should be a created for this pragma.

Questions? Ask the ACAA Technical Agent