(j3.2006) Did we intend to prohibit this?
Fri Mar 10 02:13:30 EST 2017
Van Snyder writes:
>On Fri, 2017-03-10 at 15:38 +0900, Cohen Malcolm wrote:
>> >Sure. So why is F(X) a function result *variable* in
>> > v = f(x)
>> It is not.
>I thought you said it was.
No I did not, I said the exact opposite:
"The result of a function with an allocatable result variable is not itself
variable and therefore not allocatable. It's just a value."
>So how does it get deallocated?
"it" is not a variable, so does not get deallocated (in the Fortran language
sense of "deallocated").
You know what the function result variable is, and it is not the value that
is returned by the function, nor has it ever been. The result variable is
what gets deallocated.
?When execution of the function is complete, the value of the function
result is available for use in the expression that caused the function to be
I imagine that the availability the of the value supports the first usage
above but not the second.
The design of functions with allocatable result variables was discussed in
detail during the design of the "allocatable component" feature (which also
added allocatable dummy arguments and allocatable result variables). The
end result was that the result variable is allocatable within the function
body, the value of the function was merely a value. The purpose of this was
to make it easier to write array-valued functions where you only decide what
shape array to return during execution of the function. To that end, on
return from such a function, we require the result variable to be both
allocated and given a value ("defined").
Yes, this design is very different from that of pointer functions, which
return an association rather than a value per se. We were trying for
"improved array-valued functions", not "limited pointer-valued functions".
.............Malcolm Cohen, NAG Oxford/Tokyo.
More information about the J3