To: J3 J3/23-187 From: Brad Richardson Subject: Shorthands for Simple Templates Date: 2023-June-13 #Reference: Introduction: ------------- A common observation of the current approach to templates is that it is rather heavyweight for some simple use cases. Much of this burden is due to the imposition of "strong concepts". Subgroup wishes to explore mechanisms for lightweight templated procedures. As example, consider a template like the following: template log10_tmpl(k) integer, constant :: k private public :: log10 interface log10 procedure log10_local end interface contains simple elemental function log10_local(x) result(r) real(k), intent(in) :: x real(k) :: r r = log(x) / log(10._k) end function end template which would be used like use kinds_m, only: wp instantiate log10_tmpl(wp) real(wp) :: x, y x = 42._wp y = log10(x) It would be preferable if there a shorthand way to write such a "simple" template, and a way to use such a simple template without requiring an explicit instantiate statement. What may be a possible approach is to invent new syntax for procedure definitions and procedure references which can allow the specification of the required information in a less verbose way. A plausible syntax may be something like template function log10(x) result(r) integer, constant :: k real(k), intent(in) :: x real(k) :: r r = log(x) / log(10._k) end function which would then be equivalent to the expanded example above. A plausible syntax for how it could then be used without an explicit instantiation would then be something like use kinds_m, only: wp real(wp) :: x, y x = 42._wp y = log10(x) Further exploration of possible syntax and clear delineation of the cases in which the shorthand notation is allowed is required.