J3/05-103r1 Date: 8 February 2005 To: J3 From: Van Snyder Subject: Compute whether an actual argument is present Reference: 03-258r1, section 2.8.1; 04-192, 04-357r1 04-393 Number: TBD Title: Compute whether an actual argument is present. Submitted By: J3 Status: For consideration. Basic Functionality: Provide a mechanism to compute whether an actual argument is present. Rationale: If the presence of an argument controls whether a calculation is performed, and if the desire to perform the calculation is determined by the results of other calculations, one needs to be able to compute whether the argument is present or absent. In Fortran 2003, the way to do this is with an IF construct. But with n arguments, one needs a 2^n-way if-elseif...-else-endif construct with a different one of the 2^n possible combinations of present actual arguments in each branch. It would be more convenient if one could use a syntactic form for an actual argument to calculate whether it is present. It is important that the desired entity, not the value of it, is the actual argument. Otherwise, it would not be useful where the associated dummy argument does not have INTENT(IN). Estimated Impact: This is part of the proposal in J3 paper 04-393, whose antecedent was 04-357r1. At J3 meeting 169, the proposal in 04-357r1 was judged to be at 4 on the JKR scale. Surely this proposal, being only part of the previous one, is not larger. Detailed Specification: Provide a mechanism to compute whether an actual argument is present. If the condition specifies that the actual argument is present, to be useful in the case the desired entity is not an expression, or is a procedure argument, it, rather than the value of it, must become the actual argument. No matter what syntax is used, if there is no special description it cannot be called a function or operation, because the result would be a value separate from the desired entity itself. If the condition specifies that the actual argument is absent, neither the entity that would otherwise become the actual argument, nor any expressions within it, shall be evaluated. That the condition specifies the entity is considered to be absent might be a proxy for the nonexistence of values necessary for these evaluations. Examples: Several syntaxes are possible. Two under consideration are similar to a function reference, and similar to an operator. CALL MY_SUB ( A, IF(PRESENT(B),B(:,I)) ) or CALL MY_SUB ( A, PRESENT(B) ? B(:,I) ) History: