Alvaro Fernandez writes:
> Hm. I thought it was pretty clear.
> I meant in PUBLIC statements. Like so:
I often think I'm pretty clear when nobody else agrees also. :-(
To me, redeclaring one attribute of a subroutine is a very different
thing from redeclaring the subroutine (which would mean redeclaring
*EVERYTHING* about it). I'd call that redeclaring the PUBLIC attribute
for the subroutine.
> module a
> private
> public :: sub1
> contains
> subroutine sub1()
> ...
> end subroutine sub1
> end module a
>
> module b
> use a
>
> private
> public :: sub1,sub2
.....
WOA! In your initial post, you said "assume all modules are
default public", so I did. The above modules are *NOT*
default public; they are default private. It makes a difference.
In this case, the explicit PUBLIC declaration for sub1 in module B
*IS* needed. That's because the default accessibility in module B
is private.
The PUBLIC and PRIVATE attributes are different from all the other
attributes. At times I wish they weren't called attributes at
all, but it's a bit late for that. Public and private aren't
what I would call attributes of the subroutine at all - they just
control whether or not the module makes the name accessible via
USE. As such they do *NOT* "stick" with the subroutine - they
only apply to the particular module that they are declared in.
That's why they are the only attibutes in f95 that you can specify
for something USE'd from a module.
In your module B, the default accessibility is PRIVATE, so everything
in it is private unless explicitly specified otherwise. The fact that
sub1 was PUBLIC in module A has no bearing on this except that if it
weren't PUBLIC in module A then the question would be moot - it
wouldn't be accessible to module B to have any attributes at all.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|