[J3] Can multiple specific binding of a generic type-bound procedure points to one specific type-bound procedure?
Kurt W Hirchert
kurthirchert at gmail.com
Tue Jul 15 15:48:34 UTC 2025
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/66ed3ebb/attachment.htm>
More information about the J3
mailing list