(j3.2006) Absurdity concerning the PROTECTED attribute.

Van Snyder Van.Snyder
Mon Mar 30 15:55:37 EDT 2015


There appears to be an asurdity concerning the PROTECTED attribute.

In 10-007r1, 5.3.15p2 says "Other than within the module in which an
entity is given the PROTECTED attribute, or within any of its
descendants... it is not definable...."

Consider these modules:

module m1
  integer :: I
contains
  subroutine S1
    i = 42
  end subroutine S1
end module m1

module m2
  use m1, only :: I
  protected I
end module m2

module m3
contains
  subroutine S3
    use M1, only: I
  ! use M2, only: I
    i = 666
  end subroutine S3
end module M3

Is I definable in subroutine S1 in module M1?  5.3.15p2 says not.  This
is absurd.  How about in subroutine S3 in M3?  Definablilty depends upon
which USE statement is not a comment.  This seems to be nearly as
equally absurd.

This begs for an interp.

Should it be prohibited to confer the PROTECTED attribute upon an entity
that is accessed by use association, or should 5.3.15p2 be revised:
"Where an entity is accessed by use association, if it has the PROTECTED
attribute in the module from which it is accessed then...?"  The former
is simpler, and seems more sensible than the inconsistent alternative,
i.e., allowing or prohibiting definabililty in S3 depending upon whether
I as accessed from M1 or M2.

I'll write an interp, but it would be nice to have consensus regarding
on which side of the court the ball will drop.





More information about the J3 mailing list