To: J3 J3/12-176 From: Van Snyder Subject: Another go at generic programming Date: 2012 October 05 1. Introduction --------------- Richard Maine pointed out approximately a decade ago that there is a serious problem in integrating parameterized derived types and type-bound procedures: One might declare an object with kind type parameter values that aren't supported by any of the type-bound procedures bound to it. We've had three unsuccessful attempts to address this problem: 1. Parameterized modules, 2. Macros, and 3. An informal e-mail-only proposal to allow procedure definitions within type definitions. A fourth proposal is presented here: parameterized subprograms. 2. Parameterized subprograms ---------------------------- A parameterized subprogram is one that has kind type parameters (and later perhaps other varieties of parameters, such as types). It cannot be invoked. Rather, it is necessary to declare a specific instantiation of it, with values for its parameters. One can think of it as an abstract procedure, a procedure template, or as being related to a specific instantiation of it in the same way that a parameterized derived type definition is related to objects of the type. Parametrized subprograms are less general than parameterized modules or macros, but are not inconsistent with either one. If parameterized subprograms are provided, one or both of the first two approaches could be added later. It would probably be a bit easier to read a type definition that uses this method than to allow a procedure definition within a type definition; the latter probably ought not to be pursued unless we want to use it as C++-like cryptic syntax for "maybe the processor should inline this type-bound procedure." A complete specification is provided in 12-181.pdf, in the form of an ISO Technical Specification.