To: J3 J3/19-215 From: Van Snyder Subject: Considerations for generic programming methods Date: 2019-August-08 There are at least four possibilities concerning generic programming: 1. Fortran-aware macros 2. Parameterized modules 3. Parameterized procedures (described as "templates" in 18-281r1) 4. Do nothing Pro Fortran-aware macros: 1. Essentially complete before being removed. 2. Not terribly difficult for the standard because macros produce token sequences. 3. Not terribly difficult for processors because macros produce token sequences. 4. Current design includes macro DO and macro IF. 5. Would not conflict with parameterized modules. Con Fortran-aware macros: 1. A bit clunky. 2. Processor can check only the syntax of macro definition statements. 3. Processor cannot check that result of instantiation will be valid Fortran syntax. 4. Processor cannot check that result of instantiation will have valid Fortran semantics. Pro parameterized modules 1. Look like Fortran. 2. Well-described in the context of Ada generic packages. 3. Could be extended to put requirements on generic parameters, e.g., a parameter is required to be a type name. 4. Processor could verify that result of instantiation will be valid Fortran syntax. 5. Would not conflict with Fortran-aware macros. Con parameterized modules 1. Starting nearly from scratch concerning words in the standard. 2. If parameterized module definition is required to be valid Fortran syntax, exceptions to constraints and other normative text will be necessary within module definition. 3. Processor cannot verify that that result of instantiation will have valid Fortran semantics. 4. Adding functionality of macro DO and macro IF would be desirable. 5. If standard work is not completed in a timely manner, might end up with nothing. Pro parameterized procedures 1. A tiny bit less work than parameterized modules Con parameterized procedures 1. More work than Fortran-aware macros. 2. Parameterized modules do everything that parameterized procedures would do.