(j3.2006) Finalization ordering question

Michael Ingrassia michaeli
Fri Oct 12 14:09:00 EDT 2007


>This "arrays are just a collection of scalars" idea does not apply 
>here.  The user can specify different final routines for scalar and each 
>rank of array objects.

Arrays as collection of scalars seems to apply even here.
Or how do you escape [04-007:59:9-11]
"If the entity being finalized is an array, 
each finalizable component of each element of that entity is
finalized separately.".
 
I can't visualize this stuff without examples.
In the case (apologies for syntax errors)

MODULE FOO
TYPE C			! This is a finalizable derived type.
INTEGER c
CONTAINS
FINAL :: FANCY1, FANCY2
END TYPE C

CONTAINS
SUBROUTINE FANCY1(FINALIZEE)    ! We can finalize scalars of TYPE(C)
TYPE(C) :: FINALIZEE
END SUBROUTINE FANCY1
SUBROUTINE FANCY2(FINALIZEE)    ! We can differently finalize arrays
TYPE(C) :: FINALIZEE(*)
END SUBROUTINE FANCY2
END MODULE FOO

TYPE T			! This is a finalizable basetype.
TYPE(C) :: ft
END TYPE T

TYPE, EXTENDS T :: E	! This is a finalizable extended type.
TYPE(C) :: fe
END TYPE E

TYPE(E) :: X(3)         ! X(3) is a finalizable data entity.  

To finalize X(3) following steps (1)-(3) on page 59:

(1) Nothing to call at this point as E has no final subroutines.
(2) Finalize the fe component in X(1), X(2), X(3)
	This would be the same as
		CALL FANCY1(X(1)%fe)
		CALL FANCY1(X(2)%fe)
		CALL FANCY1(X(3)%fe)
	I don't see any opportunity at all to be calling FANCY2,
	even if
		CALL FANCY2(X(1:3)%fe)
	would be potentially useful.
(3) Finalize "the parent component" of entity X(3).
    The entity X(3) is an array.  Therefore it doesn't have a parent
	component, although its type does.  Right?
	Structures (which are scalars) have components, and
	derived types have components, but arrays only have elements.
    I don't see that the standard language is correct here, although
	finalizing X(1)%T%ft, X(2)%T%ft, X(3)%T%ft
	seems like a good guess at what is intended.

What am I misreading?

In sum:  I don't think the standard even spells out what to do
for Bill's case, so we need an interp.

	--Michael I.



More information about the J3 mailing list