J3/04-225 Date: 2004-01-29 To: J3 From: fortran.com Subject: Enhancements to COMPLEX data type Reference: Pub-115 This was submitted by James Giles jamesgiles@att.net =========================================================== Number: Title: Enhancements to COMPLEX data type Submitted by: J3 Status: For Consideration References: FCD, Sections 2, 4, and 13 Basic Functionality: Add various features to the use of COMPLEX data type and arguments to make it more convenient and more consistent. Rationale: Various rules concerning COMPLEX are archaic and poorly integrated into the modern language due to backward compatibility issues. This permits writing code in a manner more consistent with the rest of the language and clearer. Estimated Impact: This has no effect on existing compliant codes. The necessary implementation problems are mostly identical to those of derived types. Detailed Specification: This is a brief specification: 1. Designators for COMPLEX variables and named constants are allowed to use the % component selection character and the names R and I (for Real and Imaginary parts respectively). For example, if Z is a complex variable, the following assignment will change the imaginary part of Z without referencing the real part of Z: Z%I = 1.0 Note that this isn't possible with the present rules. 2. Add an intrinsic function with syntax consistent with constructors of derived type data in section 4.5.9. Since COMPLEX is intrinsic, we can permit the syntactic sugar of allowing the KIND specification to be omitted. The KIND of the result in that case follows the usual KIND promotion rules (the KIND of the result is the same and the most precise KIND of the operands). With the KIND omitted, both operand expressions must be REAL. Since the semantics is more consistent with expectations than the CMPLX intrinsic, this form is to be preferred for most uses. 3. (a little more syntactic sugar) Add a new intrinsic operator (.i.) whose meaning is "i times" its argument. Hence, X + .i.Y will read as "X plus i times Y". If both X and Y are real, this is the same as COMPLEX(X,Y). This form should be permitted in the constriction of constants (and in §4.1.2 and §4.4.3) History: Submitted as Pub-115