[J3] Can multiple specific binding of a generic type-bound procedure points to one specific type-bound procedure?
Daniel Chen
cdchen at ca.ibm.com
Tue Jul 15 16:06:24 UTC 2025
Hi Kurt,
Yeah, it makes sense to me.
I missed the overriding part of the story. It would be ambiguous.
Thanks,
Daniel
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Kurt W Hirchert via J3 <j3 at mailman.j3-fortran.org>
Date: Tuesday, July 15, 2025 at 11:48 AM..
To: Daniel Chen via J3 <j3 at mailman.j3-fortran.org>
Cc: Kurt W Hirchert <kurthirchert at gmail.com>
Subject: [EXTERNAL] Re: [J3] Can multiple specific binding of a generic type-bound procedure points to one specific type-bound procedure?
It appears nonconforming to me, not specifically because assign and otherassign are the same procedure, but because they have the same interface and thus violate the rules for creating unambiguous generics. While it could be argued that this
It appears nonconforming to me, not specifically because assign and otherassign are the same procedure, but because they have the same interface and thus violate the rules for creating unambiguous generics. While it could be argued that this ambiguity is benign for type(dt), since either resolution selects the same actual procedure (myassign), this would not be true for class(dt), because assign and otherassign can be separately overridden in extensions of dt.
Does my reasoning sound right yo you?
-Kurt
On 7/15/2025 8:32 AM, Daniel Chen via J3 wrote:
Hello all,
Is the following program legal?
```
module m
type dt
integer i
contains
generic :: ASSIGNMENT(=) => assign
procedure, pass :: assign => myassign
generic :: ASSIGNMENT(=) => otherassign
procedure, pass :: otherassign => myassign
end type
contains
subroutine myassign(x,y)
class(dt), intent(out) :: x
integer, intent(in) :: y
x%i = y + 1
end subroutine
```
Generic defined ASSIGNMENT(=) has 2 specific binding names (“assign” and “otherassign”), but they all point to the same specific module procedure “myassign”.
It seems OK to me as I can’t find any wording in the standard to disallow it.
Any comments are very welcome!
Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250715/ca15a1df/attachment.htm>
More information about the J3
mailing list