Print

Print


That's a good question.

I do not think this was intended to conform.

Certainly the two generic specifications do not satisfy the rules in (F2008) "12.4.3.4.5 Restrictions on generic declarations", which apply to
" every pair of specific procedures that have the same generic identifier within the scope of the identifier"

Obviously module m scope includes the ASSIGNMENT(=) specific procedure specified by the INTERFACE.

So you ask what is the scope of the type-bound generic, and the answer is:
  " A generic binding for which the generic-spec is not a generic-name has a scope that consists of all scoping units
 in which an entity of the type is accessible."

I think this wording is not what we meant, because it leads to the surprising results that
a) a scoping unit that uses the module and has an entity of the type is not conforming;
b) adding "TYPE(T) X" to the module would make it non-conforming.

That would be a bit strange.

So I think what we meant was "the type or an entity of the type is accessible".  As the designer of the feature, it is what I implemented...

...so I think the committees need to examine this possible defect in the language standard and see what, if any, action should be taken.

I note that Bill's longer example is unambiguously NOT conforming, as the scoping unit for program m has an entity of the type, and the interface-block-specified generic is also in the scope (made accessible by use association), so violates the generic ambiguity rules.  The compilers he tested were also NOT conforming (at least with the options he used) as diagnosis of scoping rule violations is required, and this includes the generic ambiguity rules by reference.

The idea that type-bound generics override interface blocks is an interesting idea, but not one that has any support in the standard.

Cheers,
-- 
..............Malcolm Cohen, NAG Oxford/Tokyo.

-----Original Message-----
From: Fortran 90 List <[log in to unmask]> On Behalf Of Vipul Parekh
Sent: Friday, March 23, 2018 3:10 AM
To: [log in to unmask]
Subject: [COMP-FORTRAN-90] Question on overloading defined assignment with a type-bound procedure

Does the following code conform to the standard considering the assignment interface as well as a type-bound generic?

module m
   type :: t
   contains
      procedure :: assign_class_t
      generic :: assignment(=) => assign_class_t
   end type
   interface assignment(=)
      module procedure assign_t
   end interface
contains
   subroutine assign_t( this, rhs )
      type(t), intent(out), allocatable :: this
      type(t), intent(in)  :: rhs
   end subroutine
   subroutine assign_class_t( this, rhs )
      class(t), intent(inout) :: this
      type(t), intent(in)     :: rhs
   end subroutine
end module m

Two processors I tried compiled the code with no errors.

Thanks,
Vipul Parekh