Re: [MPI3 Fortran] Fortran extra_state argument to MPIattributefunctions
N.M. Maclaren wrote:
Using tokens for such things has major software engineering advantages, not least because you can check them for validity (e.g. scoping errors) before use. Except that *integers* are the wrong way to do that! If they were, we would call them "tokens" and not "integers". Sets are sets, and integers are some particular set which has, for example, addition attached to it, something tokens probably not ought to.
Forcing everyone to use an integer (an index) suffers from major extensibility problems, which is *bad* software engineering in my books. For example, once you choose "5" to mean "I am passing array foo as an extra argument", everyone has to remember that and honor that, and this is simply a bad idea.
Even in C, checking arbitrary pointer values for validity relies on undefined behaviour. Correct, and languages more modern than C, including Fortran 2003, have a good (maybe not the best) way to do "checked" pointers, namely, using "CLASS(...), POINTEr". These are (partially) typed, and can only be pointed to things of the right type and with the TARGET attribute, but are also extensible. You can make them act like integers and thus be even more checkable (for example, restricted to a small finite set of possible values), or TYPE(C_PTR) (an address), according to your desires. Instead of forcing everyone to use integers just because that happens to be the one single intrinsic type that can be used to index a set.
But the point here is to find something for MPI. In most MPI codes, I am sure people will not check the integer handles and in fact simply do illegal things like Jeff mentioned: pass the first element of an array and that way later refer to the whole array. Also, the C interface already uses void*, and trying to do "better" than that seems pointless. I though the decision was not to "modernize" the MPI interface but rather try to emulate the C interface as closely as possible. Best, Aleks -- Aleksandar Donev, Ph.D. Lawrence Postdoctoral Fellow @ LLNL High Performance Computational Materials Science and Chemistry E-mail: [email protected] Phone: (925) 424-6816 Fax: (925) 423-0785 Address: P.O.Box 808, L-367, Livermore, CA 94551-9900 Web: http://cims.nyu.edu/~donev
participants (1)
-
Aleksandar Donev