May 16 00:54 1996 X3J3/96-098R1 (2 Pages) Page 1 X3J3/96-098R1 To: X3J3 From: Richard Maine Subject: Intent for Pointer Arguments Jor item 58 requests a "regularization of the handling of pointer arguments." The primary change suggested is to allow the specification of INTENT for pointer arguments; the other suggestions all depend on this. This Jor item was identified by the U.S. in August 1995 as a medium priority requirement for f2k. Jor item 65 is also essentially equivalent. WG5 repository item 44 corresponds to this Jor item and is supplemented by WG5 repository item 44a, which simillarly requests the specification of INTENT for pointer arguments. This paper is a proposal for a detailed specification of this feature. 1. A pointer dummy argument may be specified to have an INTENT. As with non-pointer arguments, the INTENT may be specified as IN, OUT, or INOUT, or it may be left unspecified. 2. The specification of INTENT relates only to the association of the pointer, not to the value of the target. Rationale: As both repository items 44 and 44a note, there seems little useful functionality in most other choices. If the association of the pointer can change during execution of the procedure, then it makes little sense to talk about the INTENT of the target(s). If the pointer has INTENT(IN), then there do seem to be two useful possibilities. You might want to allow or disallow changing the value of the target during execution of the procedure. WG5 item 44a suggests that these possibilities are covered by making the dummy argument a non-pointer, but I am not entirely convinced. Making the dummy argument a non-pointer would disallow such things as testing its association status; for example, it is not allowed to have a disassociated pointer as an actual argument for a dummy non-pointer argument. A straw vote of x3j3 favored the approach suggested in the repository, where the INTENT applies solely to the pointer association. End rationale May 16 00:54 1996 X3J3/96-098R1 (2 Pages) Page 2 3. The INTENT of a dummy pointer limits the way in which the dummy can be used in the subprogram. These limitations closely parallel those currently specified in 12.5.2.1 of the f95 dis. 3a. If a dummy pointer has INTENT(IN), its association may not be changed during execution of a procedure. 3b. If a dummy pointer has INTENT(OUT), it is initially disassociated on entry into the procedure. 3c. If a dummy pointer has no INTENT specified, its association may be changed only if the actual argument is a pointer variable. 4. The INTENT of a dummy pointer limits the nature of the actual arguments that can be associated with the dummy. These limitations closely follow those currently specified in section 12.4.1 for non-pointer arguments. There are only two possible forms for an actual argument corresponding to a dummy pointer argument. The actual argument may be a pointer variable or it may be a pointer function invocation. 4a. If a dummy pointer has INTENT(OUT) or INTENT(INOUT), then the actual argument must be a pointer variable. 4b. If a dummy pointer has unspecified INTENT, then the actual argument must be a pointer variable if the association of the dummy argument is redefined. 4c. If the dummy pointer has INTENT(IN), then there are no extra restrictions on the allowable actual arguments. 5. A few other places clearly need some edits, but they seem almost mechanical. For example, 5a. Section 5.1.2.3 pretty much says the same kinds of things as sections 12.5.2.1 and 12.4.1. Presumably we would like these sections to continue to roughly agree. 5b. The document needs a global search for INTENT to do the actual edits, but we don't yet need that at this stage. Note that allowing pointer dummy arguments to have specified INTENT automatically has the effect of allowing defined operators on pointer operands as requested in Jor item 65. There is no explicit prohibition of defined operations with pointer operands; they were disallowed indirectly because defined operators require dummy May 16 00:54 1996 X3J3/96-098R1 (2 Pages) Page 3 arguments with specified intents. An example of a defined operation on pointers should be included when the edits are made. We will also need to search to make sure that we find and remove any mentions of the former indirect disallowance of such defined operations. Note also that although you can have defined operations with pointer dummy arguments, the pointer attribute cannot be used for disambiguation.