(j3.2006) Finalization ordering question

Aleksandar Donev donev1
Fri Oct 12 12:58:48 EDT 2007


On Friday 12 October 2007 09:03, Bill Long wrote:

> The user can specify different final routines for scalar and each
> rank of array objects. As far as I can tell, said routines can do
> completely different things for each rank.
Ah, yes, that strange feature (maybe some day I will understand it). Doesn't 
that answer your question why the specified order is used: Instead of 
finalizing the elements one by one, you finalize each of the levels of the 
type hierarchy separately, and you finalize the whole array.

> Anyway my feeling is FORTRAN users not familiar with C++ would likely find
> the finalization thing difficult to work with. ?And in fact he'll likely
> have to re-learn the lessons already learnt from similar features in other
> languages, such as destructors in C++.
A long time ago when I first read the F2003 draft I complained about 
finalizers, particularly the rigid way and ordering in which they call 
finalizers for their parent types without allowing the user to change the 
behavior. In any way, I was told then (by Richard Maine) that finalizers were 
not like destructors (just like constructors are not like C++ constructors) 
and were in fact not added to the language to provide "destructors" (this is 
why we don't have the corresponding "initializer" TBP feature). I was told 
finalizers were added because of memory management issues related to array 
expressions and temporaries and allocatable components (sorry I am 
misquoting). Maybe it just got out of control and turned into a feature that 
affects all types in somewhat confusing ways...

Aleks




More information about the J3 mailing list