07-186 To: J3 From: Van Snyder Subject: Automatic polymorphic variables Date: 2007 April 23 1 Introduction In Fortran 2003 we left polymorphic assignment to Fortran 2008. We were fortunately able to develop a compatible extension. Automatic variables can automatically get values for length parameters or array bounds, but cannot get their type. Variables of the same type as the dynamic type of a dummy argument or a module variable would be useful. There is no obvious extension that is compatible with MOLD=, so if we anticipate doing this, now is the time to do it (assuming we don't want a kludge). As things stand, the only way to get them is to allocate them. Automatic variables are simpler to program, and might have a slight edge of performance over explicitly allocated ones because the processor might invoke the memory manager only once when the specifcation part is elaborated to allocate space for all local variables, automatic or otherwise. 2 Proposal Allow TYPEOF(variable ) in place of declaration-type-spec except in IMPLICIT, or in place of type-spec in an array constructor or ALLOCATE statement. Delete MOLD= from the ALLOCATE statement. 3 Edits Edits refer to07-007r1. Page and line numbers are displayed in the margin. Absent other instructions, a page and line number or line number range implies all of the indicated text is to be replaced by associated text, while a page and line number followed by + (-) indicates that associated text is to be inserted after (before) the indicated line. Remarks are noted in the margin, or appear between [ and ] in the text. [47:22+] ---------------------------------------------------------------- or TYPEOF ( ) [47:28+] ---------------------------------------------------------------- or TYPEOF ( ) [47:37] ------------------------------------------------------------------ [Editor: Append a sentence to the paragraph:] If TYPEOF() appears the declared and dynamic types and type parameters specified are those of . [65:7+]------------------------------------------------------------------ C440a (R441) If is TYPEOF(), shall not be polymor- phic and its type parameter values shall be specified by initialization expressions. [84:14] ------------------------------------------------------------------ [Editor: Insert "If appears and is TYPEOF() the array constructor is polymor- phic if and only if is polymorphic. Every type parameter of shall have a defined value." before "If ". Insert "and is not TYPEOF()" after "appears".] [84:15-16] --------------------------------------------------------------- [Editor: Replace "this type and type parameters" by "the type and type parameters of the ".] [87:15-16] --------------------------------------------------------------- [Editor: Insert "If TYPEOF() appears the entities are polymorphic if and only if is polymorphic. Every type parameter of shall have a defined value. If TYPEOF does not appear, the". before second "The"] [88:8+]------------------------------------------------------------------ C503a (R503) If is TYPEOF() and is polymorphic, shall not be the name of a dummy argument or function result variable. [88:36] ------------------------------------------------------------------ [Editor: Insert ", or if is TYPEOF() and is polymorphic or has a type parameter that is assumed, deferred, or specified by a specification expression" at the end of the sentence.] [88:37+] ---------------------------------------------------------------- C513a An automatic data ob ject shall not have the ALLOCATABLE, EXTERNAL, INTRINSIC, PARAMETER, POINTER or SAVE attribute. [110:7+] ---------------------------------------------------------------- C579a (R560) The shall not be TYPEOF(). [127:13] ----------------------------------------------------------------- [Editor: Delete.] [130:15] ----------------------------------------------------------------- If appears and consists of TYPEOF(), the value of need not be defined, but the values of its type parameters shall be defined. [306:19+] --------------------------------------------------------------- C1215a (R1212) If is TYPEOF(), shall not be poly- morphic. [326:30+] --------------------------------------------------------------- C1248a (R1226) If is TYPEOF(), shall not be polymorphic.