-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Clause 10Standard Clause 10: Expressions and assignmentStandard Clause 10: Expressions and assignment
Description
The 202X standard will include a new attribute for procedures, simple
. If a procedure is simple
it depends on, and uses only its arguments, and calls only simple
procedures. This means that, in theory, if a simple function
's arguments are themselves constant expressions, it could be evaluated before program startup. I contend that this would be quite valuable for defining named constants of derived types whose components are private. For example given a string type defined like
module string_m
implicit none
private
public :: string_t
type :: string_t
private
character(len=:), allocatable :: str_
end type
interface string_t
module procedure constructor
end interface
contains
simple function constructor(str) result(string)
character(len=*), intent(in) :: str
type(string_t) :: string
string%str_ = str
end function
end module
It should be possible to define something like the following
type(string_t), parameter :: lines(*) = &
[ string_t("Hello, World!") &
, string_t("It's a great day!") &
, string_t("Hooray Fortran!") &
]
jacobwilliams, certik and milancurcic
Metadata
Metadata
Assignees
Labels
Clause 10Standard Clause 10: Expressions and assignmentStandard Clause 10: Expressions and assignment