[J3] Parent component name collision

Daniel Chen cdchen at ca.ibm.com
Sat Feb 8 23:39:01 UTC 2025


Thanks Malcolm!
Daniel

From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org>
Date: Friday, February 7, 2025 at 9:48 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, No conflict. Just because the components are invisible does not mean they don’t exist: they absolutely do. But invisible, so “no [accessible] name” = “no conflict”. Cheers, -- .. . . . . . . . . . . . . Malcolm Cohen, NAG Oxford/Tokyo. From: J3

Hi Daniel,

No conflict.

Just because the components are invisible does not mean they don’t exist: they absolutely do.

But invisible, so “no [accessible] name” = “no conflict”.

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

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Daniel Chen via J3
Sent: Saturday, February 8, 2025 12:39 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Daniel Chen <cdchen at ca.ibm.com>
Subject: Re: [J3] Parent component name collision


Hi Malcolm,

Oh, I could have accidentally sent it to Tom only. Sorry about that.

The standard says [19.5.4] Inheritance association

“Inheritance association occurs between components of the parent component and components inherited by type

extension into an extended type (7.5.7.2). This association is persistent; it is not affected by the accessibility of

the inherited components.”
Is this conflict to the scoping rule that makes the code conforming in this case?

Thanks,
Daniel

From: J3 <j3-bounces at mailman.j3-fortran.org<mailto:j3-bounces at mailman.j3-fortran.org>> on behalf of Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
Date: Thursday, February 6, 2025 at 6:33 PM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp<mailto:malcolm at nag-j.co.jp>>
Subject: [EXTERNAL] Re: [J3] Parent component name collision
Hi Daniel, I don’t see where Tom brought up anything about inheritance association. If you mean his email talking about component order, that is an invisible red herring so I didn’t mention it. Nor do I understand what you mean by “accessibility

Hi Daniel,

I don’t see where Tom brought up anything about inheritance association. If you mean his email talking about component order, that is an invisible red herring so I didn’t mention it.

Nor do I understand what you mean by “accessibility doesn’t matter”. Of course accessibility matters: if something is not accessible, it is as if the name is not even there, so it is impossible for it to cause a name conflict.

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

From: J3 <j3-bounces at mailman.j3-fortran.org<mailto:j3-bounces at mailman.j3-fortran.org>> On Behalf Of Daniel Chen via J3
Sent: Friday, February 7, 2025 4:27 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
Cc: Daniel Chen <cdchen at ca.ibm.com<mailto:cdchen at ca.ibm.com>>
Subject: Re: [J3] Parent component name collision

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<mailto:j3-bounces at mailman.j3-fortran.org>> on behalf of Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org<mailto: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<mailto:j3 at mailman.j3-fortran.org>>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp<mailto: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<mailto: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<mailto:j3 at mailman.j3-fortran.org>>
Cc: Daniel Chen <cdchen at ca.ibm.com<mailto: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/20250208/3c01b8c2/attachment.htm>


More information about the J3 mailing list