(j3.2006) lower bounds of results of array valued functions

Malcolm Cohen malcolm
Sun Jul 26 20:28:14 EDT 2009


FWIW, I agree that all of the "expression" cases should print 1.  That's 
not what Bill is reporting, but that is exactly what the standard says.

Bill Long wrote:
>
> The last value (lbound(b)) should be 1. B is automatically allocated on
> assignment. In that case, the shape of the expression is used for B, but
>   the bounds of B are not determined by the expression.
Yes they are.  I quote "with each lower bound equal to the corresponding 
element of LBOUND(expr)".  If expr is actually a whole array, that will 
not be equal to 1.

(Not that I disagree that the answer in this case should be one, but 
that's because that is what LBOUND is defined to return for it.)
>
> I'm not sure that specifying lbound(H()) to be 1 was
> actually intentional, or maybe these examples were not considered.
>   
Not everyone agrees with the F90 decision on LBOUND to draw the line 
where it did (whole arrays only, and no, parenthesised anything is not a 
whole array by definition).  Yes, the value of LBOUND for array function 
references is not very interesting.

As for "[producing the wrong answer is] more informative": *IF* we had 
decided on a different version of LBOUND 20 years ago, that might have 
been arguably "more informative" in some cases, but in these ones it is 
just wrong.  "More informative" seems to be arguing that the 20-year-old 
decision is wrong; well, I understand that viewpoint but I do think the 
time for arguing it is long gone.

(And I don't think we're going to be changing the definition of whole 
array any time soon.)

> I would expect the descriptor for the result of H() to be passed to sub,
> and 5 printed.
>   
That's not what we decided, and not what the standard says.

"allocatable" is an attribute that is only possessed by variables.  The 
return value of an allocatable array function is just an array value - 
which must be entirely defined, just like any other nonpointer 
function.  The only material difference between an allocatable array 
function and an ordinary array function is that you don't have to decide 
on the size of the result on entry to the function, and you can change 
your mind during execution of the function.  That is just about it.

Cheers,
-- 
.........................Malcolm.





More information about the J3 mailing list