(j3.2006) Finalization ordering question

Aleksandar Donev donev1
Wed Oct 24 13:19:20 EDT 2007

On Wednesday 24 October 2007 08:02, Aleksandar Donev wrote:

> What if
> there is a rank-1 finalizer in the parent type, and the array being
> finalized is rank-1. Surely you would call the rank-1 parent finalizer
> just like you would call the rank-1 finalizer for the array of extended
> type???
Looking at 04-007 section, I think that is what step 3 says. As 
Malcolm said, the parent component of an array is an array. It is the same 
for the other components, as Jim suggested, but this is why Step 2 has a 
special clause:
"If the entity being finalized is an array, each finalizable component of each 
element of that entity is finalized separately."
Step 3 has no such special clause because the intent is that the parent 
component is finalized as an array. IMVHO.

So back to Bill's example:

On Thursday 11 October 2007 16:04, Bill Long wrote:
> you have an array type(e) :: x(3) and it is finalized, the recipe in
> seems to say the finalizations has to be done in this order:
> Step 2: ?x(1)%fe, ?x(2)%fe, x(3)%fe
Yes, but in arbitrary array-element order (Step 2 does not specify any 

> Step 3: ?x(1)%ft, ?x(2)%ft, ?x(3)%ft
No, you finalize x%ft. If there is a rank-1 finalizer in the parent type, you 
call that. Otherwise, you do element-by-element.

I am quite certain this is the way it should be. It just follows from the 
basic "is a" inheritance relationship. And my reading of the words agrees 
with my assumptions.

After looking at the text again I realized what my original distaste for 
finalization was. The sentence "Final subroutines are not inherited through 
type extension and cannot be overridden." in Note 4.46. When I asked why this 
is so and complained, I was told finalization is not meant to provide a full 
facility like C++ destructors and I should not try to make it appear as 
such...clearly not everyone on the committee is/was on the same page...


More information about the J3 mailing list