Re: Big array indexes

From: Richard E Maine (nospam_at_see.signature)
Date: 11/20/04


Date: Fri, 19 Nov 2004 15:35:06 -0800

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


Relevant Pages

  • RE: excel formulas
    ... converts a number from euros to a euro member ... Counts the cells that contain numbers in a database ... Specifies a logical test to perform ... Looks in the top row of an array and returns the value of the indicated cell ...
    (microsoft.public.excel.misc)
  • Re: excel formulas
    ... member currency, or converts a number from one euro member currency ... Counts the cells that contain numbers in a database ... Specifies a logical test to perform ... Looks in the top row of an array and returns the value of the ...
    (microsoft.public.excel.misc)
  • Re: Dialog resource question
    ... that Specifies the window class of the control. ... of this array is any value other than 0xFFFF, ... If the first element is 0xFFFF, ...
    (microsoft.public.win32.programmer.ui)
  • Re: Creating Property Pages using CreateIndirect
    ... Specifies a variable-length array of 16-bit elements that contains the ... the ordinal value of a resource, such as an icon, in an executable file. ... If the first element is any value other than 0xFFFF, ...
    (microsoft.public.vc.mfc)