Open plevold opened 1 year ago
What meaningful useful action could a pure
finalizer accomplish, though?
Better would be some means for disallowing extended types from being declared with final
procedures at all.
A pure finalizer could deallocate a pointer. It could also call to a pure bind(c)
procedure to deallocate memory allocated in a foreign language. How pure a bind(c)
procedure possibly could be is of course debatable, but most compilers does currently allow it (I have to admit I haven't checked what the standard has to say on this topic).
Both of these scenarios are highly relevant in order to build robust functionality without memory leaks in situations where one need to manage memory manually.
This is quite similar to #189
@everythingfunctional you are absolutely correct. Somehow that issue did not show up when I searched for this. I'll add my initial comment to that issue. I think this issue can be closed as it is a duplicate of #189.
The standard currently says the following about pure subroutines:
This means that the code below is not valid Fortran:
The intent of this restriction is to avoid impure code being executed as a part of the pure subroutine. However, as this example demonstrates it is not sufficient a restriction to avoid impure code execution inside a pure subroutine:
As this restriction does not fulfill its purpose I think it should be removed. Polymorphic arguments with intent(out) is also very useful and it would be good to be able to use them in pure subroutines.
A possible solution: