09-208r1
To: J3
From: Malcolm Cohen
Subject: Suggested new feature for F2008
Date: 2009/05/01
1. Introduction
This is trivial, but is for WG5 to decide whether it is too late.
The only difference between this and 09-208 is the addition of the
"Example" section.
2. Description
Erik Kruyt made the following suggestion:
"R448. This is the only instance of PROCEDURE where no list is allowed. I
suggest to change binding-name into binding-name-list, and binding-name
[=> procedure-name] in binding-spec-list. Binding-spec is binding-name
[=> procedure-name]. The accompanying example in the 2003 standard
included such a list, which is now corrected to be consistent with the
rule. Is this feasible."
This is obviously feasible and obviously simple.
The example in F2003 shows we originally intended it this way anyway.
Therefore I have Specs, Syntax, and Edits.
3. Example
Consider the Fortran 2003 type definition:
TYPE frac
INTEGER num,denom
CONTAINS
PRIVATE
PROCEDURE :: frac_plus_frac => frac_plus
PROCEDURE :: frac_plus_i
PROCEDURE :: frac_plus_r
PROCEDURE,PASS(b) :: i_plus_frac
PROCEDURE,PASS(b) :: r_plus_frac
GENERIC,PUBLIC :: OPERATOR(+) => frac_plus_frac, frac_plus_i, &
frac_plus_r, i_plus_frac, r_plus_frac
END TYPE
Clearly the GENERIC statement is a lot more convenient to use than the
PROCEDURE statement. The extension would allow the above type to be
written as
TYPE frac
INTEGER num,denom
CONTAINS
PRIVATE
PROCEDURE :: frac_plus_frac => frac_plus, frac_plus_i, frac_plus_r
PROCEDURE,PASS(b) :: i_plus_frac, r_plus_frac
GENERIC,PUBLIC :: OPERATOR(+) => frac_plus_frac, frac_plus_i, &
frac_plus_r, i_plus_frac, r_plus_frac
END TYPE
The example in F2003 at [447:17-29] was similar to this; that example was
changed in the F2008 draft (because it was not valid syntax); the Edits
below reinstate the F2003 example as it used to be.
4. Specification
That the syntax for specifying a type-bound procedure be extended to allow
specifying more than one type-bound procedure in a single statement. This
is consistent with the way of declaring procedure pointer components (also
known as object-bound procedures), the procedure declaration statement and
the (MODULE) PROCEDURE statement.
5. Syntax
The name for the new syntax term is stylistically similar to the component
declaration statement (component-decl and proc-decl), and type declaration
statement (entity-decl).
PROCEDURE [ [ , ] :: ]
and
PROCEDURE ( ) [ , ] ::
where is
[ => ]
6. Edits to N1776
[73:12,14,14+] 4.5.5 R448
Replace " [ => ]"
with "";
replace ":: "
with ":: ";
add new rule
"R448a <>
[ => ]".
{The new syntax.}
[73:15,18] 4.5.5 C464, 4.5.5p1
After "appears" insert "in a ", twice.
{Improve clarity.}
[74:19] 4.5.5p2, first sentence.
"declares a ... procedure." -> "declares one or more ... procedures."
[472:40-42] C.1.3p4
Replace the three type-bound procedure statements with one
"PROCEDURE,PRIVATE :: rat_asgn_i, rat_plus_i, rat_plus_rat".
{Reinstate the example of what we originally intended to do.}
===END===