Several people have pointed out that in the modules I posted yesterday
there was nothing public. I had been writing Ada code all day, and
forgot that "private" means "everything is private," not "everything
from here onward is private."
I've changed them slightly. Now they sometimes work as I expect, and
sometimes don't.
Are they legal now? (I think not, but it would be nice if they were).
Best regards,
Van Snyder
=============================================================================
module m1
private
public foo
interface foo
module procedure foo
end interface
contains
subroutine foo ( x )
real x
print *, 'REAL foo'
return
end subroutine foo
end module m1
module m2
private
public foo
interface foo
module procedure foo
end interface
contains
subroutine foo ( x )
double precision x
print *, 'DOUBLE foo'
return
end subroutine foo
end module m2
program test
use m1
use m2
real R
double precision D
call foo (r)
call foo (d)
end program test
===============================================================================
One compiler compiles this program without complaint, and prints
REAL foo
DOUBLE foo
Another one says, at "use m2" in "test" that "foo" is an illegal generic
interface.
Apparently, one of them interprets "public foo" to apply only to the
generic name, while the other interprets "public foo" to apply both to
the generic and specific names.
If I change the procedures' specific names, even to the same name names
as each other, both compilers work and produce a program that prints the
result I expect. (But that's not an edge case).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|