J3/13-221 To: J3 From: Van Snyder Subject: Conditional actual arguments Date: 2013 December 20 Reference: 04-192, 13-222, 13-223 Title: Conditional actual arguments Submitted by: Van Snyder Status: For consideration Basic functionality: Define syntax to select an actual argument, and to compute whether an actual argument is present, depending upon conditions. Rationale: Reduces the need for pointer, target, or allocatable attributes. Avoids combinatorial explosion. Calculating whether an argument is present should have been done this way instead of 2008 kludge of considering disassociated pointer or deallocated allocatable as actual argument corresponding to nonpointer nonallocatable optional argument to be absent, which doesn't work for pointer or allocatable optional dummy arguments. Estimated impact: Minor Markham M6 conformance: We should have done it this way in the first place. Avoid combinatorial explosion. Detailed specification: Define a syntax term as an actual argument. Proposed spelling: <> .IF. .THEN. [ .ELSEIF. .THEN. ]... [ .ELSE. ] .ENDIF. When a is an actual argument, the s are evaluated in the order they appear until one is found to be true, or all have been evaluated. When a is true, no further s are evaluated, expressions within the corresponding are evaluated, the becomes the actual argument of the procedure being referenced as if it were not conditional, no further is evaluated, and expressions within the or other s are not evaluated. If no is true, no expression within a is evaluated. If .ELSE. appears, expressions within are evaluated, the becomes the actual argument of the procedure being referenced as if it were not conditional, and expressions within s are not evaluated. If no is true and does not appear, the actual argument is absent. If the and s are data objects, the declared type, kind type parameter values, and rank of the are those of the and s. The argument presence, pointer association status if any, allocation status if any, dynamic type, shape, and length type parameter values of the actual argument are those of the corresponding to the first true , if there is one, or otherwise those of the if it appears. The properties of the and s shall agree with the dummy argument in the same way as if they were not conditional. Draft edits: To estimate scope of project Insert syntax rules R1222a <> <> R1222b <> .IF. .THEN. [ .ELSEIF. .THEN. ]... [ .ELSE. ] .ENDIF. R1222c <> R1222d <> Rename R1223 as Insert a constraint C1233a (R1222b) The and s shall all be data entities with the same declared type, kind type parameter values, and rank, \obs{all be s,} or all be procedures. Insert paragraphs 12.5.1p2 etc. after C1237: "When a is an actual argument, the s are evaluated in the order they appear until one is found to be true, or all have been evaluated. When a is found to be true, expressions within the corresponding are evaluated, the becomes the actual argument of the procedure being referenced as if it were not conditional, no further is evaluated, and expressions within the or another are not evaluated. If no is true, no expression within a is evaluated. If .ELSE. appears, expressions within are evaluated, the becomes the actual argument of the procedure being referenced as if it were not conditional, and no expression within a is evaluated. If no is true and does not appear, the actual argument is absent. If the and s are data objects, the declared type, kind type parameter values, and rank of the are those of the and s. The argument presence, pointer association status if any, allocation status if any, dynamic type, shape, and length type parameter values of the actual argument are those of the corresponding to the first true , if there is one, or otherwise those of the if it appears. The properties of the and s shall agree with the dummy argument in the same way as if they were not conditional."