To: J3 J3/23-182r1 From: Brad Richardson Subject: Expanded Requirements Date: 2023-June-13 #Reference: Introduction: ------------- This paper describes extensions of the REQUIREMENT and REQUIRES template features proposed feature for F202Y. The templates feature has introduced the concept of a REQUIREMENT, which serves to encapsulate and reuse sets of declarations. In some cases it would be desirable to also specify properties of certain types or values which cannot be specified by a declaration. For example it would be nice to specify the requirement that a value be a valid kind for a given intrinsic type. For example something like, REQUIRES VALID_REAL_KIND(K) One avenue for solving the above use cases would be to allow a constant LOGICAL expression in place of REQUIREMENT in a REQUIRES statement. For example VALID_REAL_KIND could be defined as: REQUIREMENT VALID_REAL_KIND(K) USE ISO_FORTRAN_ENV, ONLY: REAL_KINDS REQUIRES any(K == REAL_KINDS) END REQUIREMENT There are some cases where there is no way to specify a logical expression that establishes a property that you want to check. There may also be some properties which the processor may need to understand semantically in order to write certain templates. This will also potentially serve a role as we allow for polymorphism with deferred types. For example something like REQUIRES EXTENSIBLE(T) may be needed in order to write a template like TEMPLATE ELEMENT_WRAPPER(T) REQUIRES EXTENSIBLE(T) TYPE :: WRAPPER CLASS(T), ALLOCATABLE :: ELEMENT END TYPE END TEMPLATE Something like REQUIRES EXTENDS_FROM(T, U) may be needed to write certain templates as well.