I'm sorry, but that's not what I mean... Clearly, you can have two
functions/routines, put them in an interface block directly or through the
MODULE PROCEDURE statement, and have the compiler pick among them by
"disambiguating" based upon the kinds of the arguments being passed in and
the kinds of the dummy arguments waiting to receive them in the procedure.
The compiler swaps the generic name sin() for sin_single_precision, and away
we go - compile-time polymorphism.
But what Van Snyder said was that he had a _single version_ which he wrote
for all kinds and selected internally. That's at least what I understood.
Alvaro
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of
Richard Maine
Sent: Monday, March 08, 2004 4:59 PM
To: [log in to unmask]
Subject: Re: configurable default real
Alvaro Fernandez writes:
> I'm afraid I don't follow how the "gluing together" works, though. I
> understand one can have two versions of the algorithm in the body, and
> branch based on the (integer) kind value, but how do you work it so your
> generic has only one set of dummy arguments?
The same way that intrinsic generics have worked since f77. I.e. the
same way that sin(x) works for both single and double precision (or
quad if you have such) x. It isn't a run-time branch. You provide
all the specific versions. Then the compiler selects *AT COMPILE
TIME* the specific version that matches the argument kinds; if there
isn't a matching specific, you'll get an error message.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|