To: J3 J3/18-273 From: Dan Nagle Subject: virtuous procedures Date: 2018-October-16 I Introduction Fortran has PURE procedures, which operate without changing global data, 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 data, 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 data is easier to offload to a device, or other off-chip processor. During development, a procedure that does not reference outside data 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 global data, 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 An attribute will be added to the standard that specifies that a procedure does not reference global data. I don't know what keyword should be used to express this. I'll use the word "local" for this attribute herein. So LOCAL would be used as PURE is now, something like LOCAL FUNCTION DOUBLE( X) REAL, INTENT( IN) :: X DOUBLE = 2.0 * X END FUNCTION DOUBLE Straw Vote: What word to use ? (open to discussion) Checking a thesaurus (thesaurus.com) for "self-contained" gives self-*, un*, autonomous, absolute, autarchic, freewheeling, individualistic, non*, separate, sovereign Checking for "local" gives provincial, regional, district, neighborhood, narrow, parish, sectarian, sectional, neighborhood, territorial, town, vernacular Checking for "pure" gives authentic, bright, classic, natural, neat, perfect, plain, real, simple, transparent, true, unadulterated I have no favorite among the above. IV (Rough) Requirements An attribute, applying to procedures, is added to the standard, which specifies that the procedure to which it applies neither references nor changes any non-local data except via its argument list. Arguments to such a procedure require explicit INTENT.