- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, everyone. The following code puzzles me:
module test
type :: tp
private
integer :: i
contains
private
generic, public :: ge => sub1, &
sub2
procedure, pass :: sub1
procedure, pass :: sub2
end type tp
contains
subroutine sub1(this, s)
class(ab), intent(in) :: this
class(*), intent(in) :: s
end subroutine sub1
subroutine sub2(this, s)
class(ab), intent(in) :: this
integer, intent(in) :: s
end subroutine sub2
end module test
And the compiler says:
Ambiguous generic interface GE: previously declared specific procedure SUB1 is not distinguishable from this declaration. [SUB2]
Is it a problem to distinguish INTEGER from unlimited polymorphic ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure it is possible, but you need an additional argument to solve the ambiguity.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps the other way around: an unlimited polymorphic variable can have any type, so indeed it can not be distinguished by type alone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SO it's not possible to have sub/funcs which have unlimited polymorphic argument in overloaded generics ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure it is possible, but you need an additional argument to solve the ambiguity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Arjen Markus wrote:
Sure it is possible, but you need an additional argument to solve the ambiguity.
Thanks I got it.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page