Thorsten Ohl writes:
> Is the following standard conforming?
Yes (with the usual caveat that I could have missed something).
> MODULE WW
> PUBLIC :: N_IN
> CONTAINS
> FUNCTION N_IN ()
> N_IN = 2
> END FUNCTION N_IN
> END MODULE WW
>
> MODULE PROCESS_INTERFACE
> PUBLIC :: N_IN
> CONTAINS
> FUNCTION N_IN () ! <=== N_IN denotes two
> USE WW, ONLY: WW_N_IN => N_IN ! <=== different objects here.
> N_IN = WW_N_IN ()
> END FUNCTION N_IN
> END MODULE PROCESS_INTERFACE
The comment is incorrent. There is only one N_IN accessible in the
scope of the comments. The USE statement makes the procedure from
module WW accessible by the name W_N_IN; it is *NOT* accessible by
the name N_IN.
Its a little hard to cite exactly where there is not a restriction
against something. The best I can do is point out how the restriction
closest to pertinent does not apply here. In 14.1.2 of f95 you will
find the material on name conflicts. One of its paras says
"Within a scoping unit, a name that identifies a local entity of one
class shall not be used to identify another local entity of the
same class except..."
Within the scoping unit of the comments, the name N_IN identifies only
one local entity - the function N_IN of module process_interface.
Within this scoping unit, the name WW_N_IN is the name that identifies
the function N_IN of module ww. Therefore, the above restriction does
not apply, and I can't imagine any other restriction that might be
pertinent.
This is pretty much the whole point of the rename clause of USE.
If it didn't avoid name clashes, it wouldn't be nearly as useful.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|