[J3] dumb question about module use not inheriting into interfaces
Robert Corbett
rpcorbett at att.net
Fri Aug 26 10:37:30 UTC 2022
Until the IMPORT statement was introduced, interface blocks did not inherit names from the surrounding scoping units. Interface blocks were supposed to have the same meaning regardless of where they appeared. That meant that definitions and declarations from the surrounding scoping units had to be ignored.
Bob Corbett
> On Aug 26, 2022, at 3:04 AM, Jeff Hammond via J3 <j3 at mailman.j3-fortran.org> wrote:
>
>
> I observe that the following code fails when the line with “REQUIRED” in it is commented-out, but I do not understand it.
>
> Why does the use inclusion of ISO_Fortran_env propagate into the contained subroutine but not the interface block?
>
> It is mildly annoying to have to add a use line to every single interface, when it is used in the module already, but I assume there is some good reason for this.
>
> Thanks,
>
> Jeff
>
> module confused
> use, intrinsic :: ISO_Fortran_env
>
> interface
> subroutine foo(buffer) bind(C,name="foo")
> use, intrinsic :: ISO_Fortran_env ! REQUIRED
> implicit none
> real(kind=REAL64), dimension(*) :: buffer
> end subroutine foo
> end interface
>
> contains
>
> subroutine bar(buffer) bind(C,name="bar")
> implicit none
> real(kind=REAL64), dimension(*) :: buffer
> end subroutine bar
>
> end module confused
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220826/572cfc57/attachment.htm>
More information about the J3
mailing list