(j3.2006) kind conversion for intent(in), value dummy arguments
Bill Long
longb at cray.com
Tue Sep 16 18:06:39 EDT 2008
Craig Rasmussen wrote:
> On Sep 16, 2008, at 1:41 PM, Dan Nagle wrote:
>
>
>> What if I had a math library supporting single and double, and
>> I wrote it with value? I suspect there's an inconvenience to be found
>> for most (every?) convenience found.
>>
>>
>
> Good point. Some languages (Standard ML for one, as I recall) don't
> even allow conversion on assignment. Fortran would be safer if it
> allowed no implicit type conversions.
>
But also less expressive in terms of writing mathematical formulas.
However, WG5 seems to be heading in your direction. If
<boz-literal-constant> were added to just 3 places in Table 7.10 (so
they were allowed as the <expr> in intrinsic assignment), then a
statement like
I = z"000000ff"
would be trivially well defined (since the semantics rely on the <expr>
being a valid argument to INT - see Table 7.11). Same for R = boz.
However, WG5 voted explicitly to not allow this form in London, even
though it is somewhat inconsistent with the rest of the language. One
might assume that dislike for implicit type conversions is at least
partly responsible. (Vendors already allow this sort of assignment in
practice anyway.)
> I'd be interested to just know how the various compilers behave in
> this respect now. I used to have several but now only two and one
> reports and error and one just a warning.
The Cray compiler gives an error message for mismatched kinds.
> For MPI interfaces, I think
> the answer is just to use default kinds and allow C wrappers to untie
> the -i4/-i8 mess.
>
Or recommend to users that they explicitly specify kinds for the integer
actual arguments to MPI routines, which avoids the -i8 problem
entirely. Users generally figure this out by the time they write their
second MPI program. Including the recommendation in the MPI
documentation could save them on the first try.
Cheers,
Bill
> Craig
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list