Version 1.1 of ais/ai-00290.txt

Unformatted version of ais/ai-00290.txt version 1.1
Other versions for file ais/ai-00290.txt

!standard 10.2.1 (00)          02-03-14 AI95-00290/01
!class amendment 02-03-13
!status received 02-03-13
!priority Medium
!difficulty Medium
!subject Declaring functions Pure
!ACATS test

From: Tucker Taft
Sent: Tuesday, March 12, 2002  4:47 PM

Thanks, Robert.  I hereby nominate this as the basis for an Amendment AI.

> As Tuck requested:
> @item pragma Pure_Function
> @noindent
> Syntax:
> @smallexample
> pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
> @end smallexample
> This pragma appears in the same declarative part as a function
> declaration (or a set of function declarations if more than one
> overloaded declaration exists, in which case the pragma applies
> to all entities).  If specifies that the function @code{Entity} is
> to be considered pure for the purposes of code generation.  This means
> that the compiler can assume that there are no side effects, and
> in particular that two calls with identical arguments produce the
> same result.  It also means that the function can be used in an
> address clause.
> Note that, quite deliberately, there are no static checks to try
> to ensure that this promise is met, so @code{Pure_Function} can be used
> with functions that are conceptually pure, even if they do modify
> global variables.  For example, a square root function that is
> instrumented to count the number of times it is called is still
> conceptually pure, and can still be optimized, even though it
> modifies a global variable (the count).  Memo functions are another
> example (where a table of previous calls is kept and consulted to
> avoid re-computation).
> @findex Pure
> Note: Most functions in a @code{Pure} package are automatically pure, and
> there is no need to use pragma @code{Pure_Function} for such functions.  An
> exception is any function that has at least one formal of type
> @code{System.Address} or a type derived from it.  Such functions are not
> considered pure by default, since the compiler assumes that the
> @code{Address} parameter may be functioning as a pointer and that the
> referenced data may change even if the address value does not.  The use
> of pragma @code{Pure_Function} for such a function will override this default
> assumption, and cause the compiler to treat such a function as pure.
> Note: If pragma @code{Pure_Function} is applied to a renamed function, it
> applies to the underlying renamed function.  This can be used to
> disambiguate cases of overloading where some but not all functions
> in a set of overloaded functions are to be designated as pure.


Questions? Ask the ACAA Technical Agent