fprettify icon indicating copy to clipboard operation
fprettify copied to clipboard

module procedure in submodule

Open implicitall opened this issue 4 years ago • 4 comments

I found that "module procedure" handling is a bit tricky. In a submodule, "module procedure" acts as a subroutine with no parameters. In an interface, it just is a generic. My hack to handle this was to add new regular expressions for module procedures. Unfortunately, for module procedures in the interface declaration, the outside scope had to be checked so that it did not cause a scope increase. That doesn't seem like an elegant solution but I don't know of another way. In any case, the point is that "module procedure" has an issue.

implicitall avatar Mar 17 '20 06:03 implicitall

Also, not to mention submodule, which is similar to a module but with a parent parameter. submodule(parent) child

implicitall avatar Mar 17 '20 06:03 implicitall

Could you give an example?

pseewald avatar Mar 17 '20 07:03 pseewald

https://github.com/scivision/fortran-submodule/blob/master/src/child.f90

implicitall avatar Mar 17 '20 07:03 implicitall

https://github.com/modern-fortran/generic-procedures/blob/master/src/mod_average.f90

In this example you don’t have to have the “::” for the generic if you don’t want. That could be a trick for parsing though if it was mandatory.

implicitall avatar Mar 17 '20 07:03 implicitall