(j3.2006) Should the PUBLIC attribute on derived type definition make generic that has the same name also public when default is private?
john.reid at stfc.ac.uk
john.reid
Thu Jul 10 16:09:50 EDT 2014
Daniel,
I think that this is a valid program. 5.3.2, para 2, says: "Identifiers that are specified in a module or accessible in that module by use association have either the PUBLIC attribute or PRIVATE attribute."
Here we have the identifier base_type and it has the PUBLIC attribute. It identifies both the type and the generic procedure.
Howsever, some clarification in 4.5.2.2 would be helpful. It talks of types having either the PUBLIC or PRIVATE attribute without saying anything about the effect on a generic identifier with the same name.
Cheers,
John.
________________________________________
From: Daniel C Chen [cdchen at ca.ibm.com]
Sent: 10 July 2014 17:28
To: j3 at mailman.j3-fortran.org
Subject: (j3.2006) Should the PUBLIC attribute on derived type definition make generic that has the same name also public when default is private?
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
--
Scanned by iCritical.
More information about the J3
mailing list