Designating SIMPLE procedures

Fortran 202x will have

‘SIMPLE’ procedures: PURE procedures with no writing or referencing beyond their
arguments

and many functions I write are SIMPLE, but it will be a while before all the currently developed Fortran compilers support the SIMPLE designation. If modern Fortranners adopt a common style to designate SIMPLE functions in comments, in the future a tool could be written to change the PURE designation to SIMPLE. A guideline could be added for the stdlib project that procedures should be commented as SIMPLE when they meet the conditions. Two commenting styles are

pure function twice(x) result(y) !! SIMPLE
real, intent(in) :: x
real             :: y
y = 2*x
end function twice

which I prefer since it does not add a line and

pure function twice(x) result(y)
!! SIMPLE
real, intent(in) :: x
real             :: y
y = 2*x
end function twice

How do people think SIMPLE functions should be designated until compilers support the label?

1 Like

Question. What can you do with simple procedures that you cannot do with pure procedures? I hadn’t yet joined the committee when this was being worked on so I’m not quite clear. I may look it up later, but seeing it explained here would be beneficial to others.

P.S. I vote for the first form, but I hope it will be as simple as search and replace all puresimple and then change back any places the compiler complains about.

3 Likes

Those into preprocessing can consider using values or macros (e.g., #define), perhaps something like PURELY_SIMPLE that can imply PURE now, but can be made SIMPLE later!!

The discussed rationale appears to be moving such procedures around e.g., use anywhere; and also improved optimization opportunities.