(j3.2006) Should parent component have the accessibility of the parent type?
Daniel C Chen
cdchen
Mon Jan 25 10:29:02 EST 2016
Thanks All!
I changed the example slightly by merging module A and B into one and make
type A_t private as:
Module AB
private
Type A_t
Integer i
End type
Type, extends(A_t) :: B_t
End type
Public B_t
End module
Module C
Use AB
Type, extends(B_t) :: C_t
End type
Contains
Subroutine sub(this)
Type(C_t) :: this
This%B_t%A_t%i = 4 !! NOT allowed
This%B_t%i = 4 !! Allowed
End
End module
Now Type A_t is private at where it is defined. Should access to "
This%B_t%A_t%i" still be allowed in module C?
Is there any case that a parent component should not be accessible at all?
Thanks,
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
From: "mark leair (PGI)" <mark.leair at pgroup.com>
To: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
Date: 01/25/2016 05:36
Subject: Re: (j3.2006) Should parent component have the accessibility
of theparent type?
Sent by: j3-bounces at mailman.j3-fortran.org
The PGI compiler does not currently allow This%B_t%A_t%i = 4 in the example
below (but it does allow This%B_t%i = 4).
I agree that it would be nice to have this clarified in F2015.
-Mark
From: j3-bounces at mailman.j3-fortran.org [
mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of Malcolm Cohen
Sent: Saturday, January 23, 2016 10:52 PM
To: fortran standards email list for J3
Subject: Re: (j3.2006) Should parent component have the accessibility of
theparent type?
Hi Daniel,
I think this is referring to the accessibility of the parent type where it
is defined, not where the extension is defined. Otherwise, as you say, it
does not make much sense. That is certainly how I interpreted it (NAG
compiles your example without complaint). I just cannot imagine how it
could make sense for an ancestor component to be popping into and out of
visibility as you go down the type tree ? either it?s visible all the way
down, or not visible at all.
Unfortunately the paper trail is not exactly clear ? paper 03-224 adds this
specification as an editorial fixup with no indication of any supposed
technical effect whatsoever. Grrr.
It might be a good idea to clarify this in F2015.
Cheers,
From: Daniel C Chen
Sent: Friday, January 22, 2016 11:26 AM
To: j3 at mailman.j3-fortran.org
Subject: (j3.2006) Should parent component have the accessibility of
theparent type?
Hello,
Consider the following code:
Module A
private
Type A_t
Integer i
End type
Public A_t
End module
Module B
Use A
private
Type, extends(A_t) :: B_t
End type
Public B_t
End module
Module C
Use B
Type, extends(B_t) :: C_t
End type
Contains
Subroutine sub(this)
Type(C_t) :: this
This%B_t%A_t%i = 4 !! NOT allowed
This%B_t%i = 4 !! Allowed
End
End module
The standard states that the parent component has the accessibility of the
parent type as follows: [16-007-p80: 2-6]
"An extended type has a scalar, nonpointer, nonallocatable, parent
component with the type and type parameters
of the parent type. The name of this component is the parent type name. It
has the accessibility of the parent
type. Components of the parent component are inheritance associated (16.5.4
) with the corresponding components
inherited from the parent type. An ancestor component of a type is the
parent component of the type or an
ancestor component of the parent component."
In the above example, "This%B_t%A_t%i" is not allowed because the parent
component "A_t" of "This%B_t" has the accessibility of type A_t, which is
private in Module B so not accessible in module C. On the other hand,
"This%B_t%i" seems fine.
Is it the intention of the standard to disallow "This%B_t%A_t%i"?
Thanks,
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
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
This email message is for the sole use of the intended recipient(s) and may
contain confidential information. Any unauthorized review, use, disclosure
or distribution is prohibited. If you are not the intended recipient,
please contact the sender by reply email and destroy all copies of the
original message.
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20160125/071597ee/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20160125/071597ee/attachment.gif
More information about the J3
mailing list