To: J3 J3/19-201 From: Nathan John Sircombe & Malcolm Cohen Subject: Draft design for SIMPLE procedures Date: 2019-August-05 Introduction ============ 18-273r1 introduces the concept of SIMPLE procedures as an extension of PURE procedures. PURE procedures operate without writing to global variables beyond their arguments, SIMPLE procedures would be further restricted from referencing global variables beyond their arguments. Requirements: ============= Introduction of a new procedure prefix for subprograms which do not reference or update global variables beyond their arguments. - A new prefix-spec, 'SIMPLE', added to the standard. - Requirements and constraints, closely following those for PURE, added to the standard. Specifications: =============== - A SIMPLE procedure is PURE. - A SIMPLE procedure is not permitted to reference or define any variable outside its arguments and local variables. - A subprogram is specified to be SIMPLE if it has a SIMPLE prefix in its initial SUBROUTINE or FUNCTION statement. - A SIMPLE procedure cannot be IMPURE. - A SIMPLE procedure may be ELEMENTAL. - A SIMPLE procedure can access derived type definitions and named constants from outside its scope, but is not permitted to reference any variables except local variables or dummy arguments. - Similarly, a specification inquiry that is not a constant expression shall not depend on a variable other than a local variable or dummy argument. (See p157 of 18-007r1 for the definition of specification inquiry.) This allows, e.g. KIND(X) where X is a variable accessed by use or host association, but not LEN(Y) unless Y has constant length. Other specifications follow from those of a PURE procedure, with the additional constraint that all internal subprograms in a SIMPLE subprogram shall be SIMPLE and all procedure references in a SIMPLE subprogram shall be SIMPLE. Syntax: ======= prefix-spec <> ! existing rules plus <> SIMPLE Thus the SIMPLE prefix-spec may appear in any position in the prefix of a SUBROUTINE or FUNCTION statement. Constraint: If SIMPLE appears, IMPURE shall not appear. (Specifying PURE is redundant but permitted.) Constraints: as described in the specs for a SIMPLE procedure. Edits ===== To follow.