To: J3 J3/18-273r1 From: Dan Nagle Subject: virtuous procedures Date: 2018-October-17 I Introduction Fortran has PURE procedures, which operate without changing global variables, except through their arguments. This allows PURE procedures to be used in parallel constructs, where concurrency issues would otherwise prevent use. One step beyond PURE is a procedure that neither references nor defines global variables, except through its arguments. This represents an entirely local calculation. As such, it may be moved, in-lined, and manipulated by the compiler (or by a pre-compiler step). II Use-cases A procedure that does not reference outside variables is easier to offload to a device, or other off-chip processor. During development, a procedure that does not reference outside variables may enable greater compiler checking of use of names that may be unintentionally associated and not locally declared. Developing and testing a procedure that references global data requires not only access to the relevant global variables, but, in many instances, requires that the variables have values at least similar to those that would be encountered during execution. This may be difficult to produce. Any "virtuous" procedure would automatically be a PURE procedure. III What I have in mind A prefix will be added to the standard that specifies that a procedure does not reference global variables. I don't know what keyword should be used to express this. Following the plenary discussion, the words "strict" and "simple" were preferred. I'll use the word "simple" for this attribute herein. So SIMPLE would be used as PURE is now, something like SIMPLE FUNCTION DOUBLE( X) REAL, INTENT( IN) :: X DOUBLE = 2.0 * X END FUNCTION DOUBLE IV (Rough) Requirements A prefix, applying to procedures, is added to the standard, which specifies that the procedure to which it applies neither references nor changes any non-local variables except via its argument list. Arguments to such a procedure require explicit INTENT.