Re: overloaded cant be distinguished by return values?
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Wed, 30 May 2007 20:22:57 GMT
Berthold Höllmann wrote:
....
module a
interface test
module procedure testa, testb
end interface test
contains
function testa() result(a)
integer :: a
a = 1
end function testa
function testb() result(b)
character(len=8) :: b
b = 'result'
end function testb
end module a
Suppose the above were allowed and you wrote the following
call:
Write(*,*) test()
Which of the instances of test should be called here?
There are some languages (like Ada, for example) where the
overloading of a generic can be determined by the result type
because there are no contexts in the language where a reference
may be written such that the required type isn't known from that
context. There's even a formal name for type mechanisms
designed that way (which I always disremember).
Fortran doesn't have that property. The type of anything in
Fortran is determined by its own appearance (like a literal),
its own declaration (like most variables and non-generic
functions), or based on the types of its operands (like operator
results or generic function references).
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
.
- References:
- overloaded cant be distinguished by return values?
- From: Berthold Höllmann
- overloaded cant be distinguished by return values?
- Prev by Date: Re: overloaded cant be distinguished by return values?
- Next by Date: Running Windows Programs from Fortran
- Previous by thread: Re: overloaded cant be distinguished by return values?
- Next by thread: compaq visual fortran, process pririty mangement option
- Index(es):