Home > Archive > Fortran > January 2006 > allow size of parameter array to be inferred?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
allow size of parameter array to be inferred?
|
|
| beliavsky@aol.com 2006-01-18, 7:03 pm |
| I wish Fortran allowed the compiler to infer the size of a parameter
array from the right-hand-side of the assignment, so that (for example)
integer, parameter :: ivec(:) = (/1,4,9/)
would be equivalent to
integer, parameter :: ivec(3) = (/1,4,9/)
This would be similar to the currently allowed usage
character (len=*), parameter :: word = "dog"
although I understand the difference -- word is a scalar. Has the
Fortran standards committee considered this idea?
| |
| Dick Hendrickson 2006-01-18, 7:03 pm |
|
beliavsky@aol.com wrote:
> I wish Fortran allowed the compiler to infer the size of a parameter
> array from the right-hand-side of the assignment, so that (for example)
>
> integer, parameter :: ivec(:) = (/1,4,9/)
>
> would be equivalent to
>
> integer, parameter :: ivec(3) = (/1,4,9/)
>
> This would be similar to the currently allowed usage
>
> character (len=*), parameter :: word = "dog"
>
> although I understand the difference -- word is a scalar. Has the
> Fortran standards committee considered this idea?
>
Yes, it's on the list of things to go into F2008. In fact,
it has passed on from specs to actual edits to the standard.
BUT, nothing is final until it's final. This is a pretty
small thing, but there's always a chance that things will
come or go ar get changed before the final version. The
paper that describes it is 05-194r1 if you want to see it.
(Actually, that's also the number even if you don't want
to see it. ;) )
The form is a little different from your example. It allows
any number of dimensions, and the upper bound for each must
be an asterisk. So you'd do
integer, parameter :: ivec(*) = (/1,4,9/)
or perhaps
integer, parameter :: ivec(-137:*) = (/1,4,9/)
Dick Hendrickson
|
|
|
|
|