[J3] Parent component name collision
Daniel Chen
cdchen at ca.ibm.com
Thu Feb 6 19:26:46 UTC 2025
Thanks Malcolm!
Does the inheritance association that Tom brought up play any role in this case as it indeed says accessibility doesn’t matter?
Thanks,
Daniel
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org>
Date: Wednesday, February 5, 2025 at 6:01 PM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: [EXTERNAL] Re: [J3] Parent component name collision
Hi Daniel, Yes, it is valid, because there is no scope in which a component name conflict occurs. Name conflicts are forbidden by the scoping rules. All the possible conflicts for non-global identifiers are “within a scope”. Name
Hi Daniel,
Yes, it is valid, because there is no scope in which a component name conflict occurs.
Name conflicts are forbidden by the scoping rules. All the possible conflicts for non-global identifiers are “within a scope”. Name conflicts cannot occur involving something that is inaccessible.
As you write, component “base” is not visible outside module m, therefore in the extension type “child”, there is only the parent component “base” and the added component “name”. No problem.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Daniel Chen via J3
Sent: Thursday, February 6, 2025 2:07 AM
To: Van Snyder via J3 <j3 at mailman.j3-fortran.org>
Cc: Daniel Chen <cdchen at ca.ibm.com>
Subject: [J3] Parent component name collision
Hello,
Is the following code legal?
```
module m
type base
integer*4, private :: base = 1 !! Not accessible outside of the module
end type
end module
program main
use m
type, extends(base) :: child
character(20) :: name
end type
end
```
There is a name collision between the parent component “base” and the integer component “base” inside of type base. However, since integer base is a private component that is not accessible outside of the module, it seems there is no ambiguity in the main program.
Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250206/168e5667/attachment.htm>
More information about the J3
mailing list