| Richard E Maine 2004-11-19, 8:57 pm |
| Janne Blomqvist <foo@bar.invalid> writes:
> In this case, I think the savior and One True Way (TM) is F2003, which
> I understand supports array indexes of non-default kind. Actually I
> haven't found the spot in the draft standard that specifies this (it
> just talks about some "scalar-int-expr"), but I have found out that
> the array intrinsic functions have an extra optional argument
> specifying the kind of the return value. Anyone care to confirm or
> deny this?
F95 also supports array indices of non-default kind. This is not
fundamentally new to f2003. You won't find anywhere that comes
out and says that they may be of nondefault kinds - that's not the
way the standard does things. Instead, the secret is in what you
will not find - namely you won't find a restriction to default kinds.
If something is required to be an integer, then that means any kind
of integer unless a restriction is specified somewhere.
However... what is new in f2003 is not that array indices are allowed
to be of nondefault kind, but that there is some support to make using
such arrays at least a little less painful. In particular, things like
the KIND arguments that you noticed on some of the intrinsics. In
f95, you could have array indices of nondefault kind, but you were
kind of hemmed in on usability because you couldn't then use a bunch
of the intrinsics without the results overflowing (and integer overflow,
which is typically not detected).
Note that those KIND arguments were adopted based on some existing
practice. Fairly obvious existing practice, but still. You presumably
can find some f95 compilers that already do that.
I'd still find using nondefault index kinds to be pretty awkward, even
in f2003, but at least they are a little less so. The main remaining
awkwardness IMO is the unreasonably large number of places that you
are likely to have to add explicit kind suffixes. I'd think life
would be a lot simpler in this area if default integer kind were just
changed to 64 bits, but I realize that would make life more complicated
in other areas (mostly in portability of the amount of old code that
assumes otherwise).
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
|