(j3.2006) Should the PUBLIC attribute on derived type definition make generic that has the same name also public when default is private?

Daniel C Chen cdchen
Thu Jul 10 12:28:53 EDT 2014



Hello all,

Is the following test case standard conforming? The default accessibility
of module 'base_mod' is private. The derived type 'base_type' is public
because of the PUBLIC attribute on the type definition. Does it make the
generic name 'base_type" also public so that the access to the generic in
the program 'test' is legal?
My understanding is that the following test case is illegal as the PUBLIC
attribute on the derived type definition only makes the type 'base_type'
public, not the generic name 'base_type', but I couldn't find anything in
the standard says either way.

Any response will be highly appreciated!

 module base_mod
 implicit none
 private

 type, public :: base_type
     private
     character(len=20) :: name
   end type

   interface base_type
     module procedure constructor
   end interface

 contains

   type(base_type) function constructor(set_name) result(this)
     character(len=*), intent(in) :: set_name
     this%name = trim(set_name)
   end function

 end module base_mod

 !-------------------------------------------------------------
 ! Top-level program.
 !-------------------------------------------------------------

 program test
 use base_mod, only: base_type
 implicit none

type(base_type) :: my_base

my_base = base_type(set_name='fish')

 end program test

Daniel

XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20140710/7a0269d0/attachment.html 



More information about the J3 mailing list