(j3.2006) Frustrating consequence of F2003 allocation semantics

Damian Rouson damian
Wed Apr 15 03:34:24 EDT 2015

> On Apr 14, 2015, at 8:41 AM, Craig Dedo CAPM <craig at ctdedo.com> wrote:
> Everyone:
>             It appears to me that the only solution would be to place the reallocation semantics of allocatable arrays into the hands of the developer, rather than being specified by the standard.  Thus, when declaring an allocatable array, the developer would have the option of specifying whether reallocation was automatic or it needed to be done explicitly. This would be another attribute. 

I would argue that the (re)allocation semantics of allocatable arrays is already in the hands of the developer.  Automatic (re)allocation can be turned off by make the left-hand side of the assignments (whole) array sections: 

buffer(:) = A
buffer(:) = C

Admittedly one could impact the source code less by adding an attribute that precludes automatic (re)allocation at the point of declaration, but an unintended side effect is that it might also obscure the programmers? intention in long scoping units where the assignment and declaration are separated by a large number of lines.  I?d much rather see the programmers' intentions at each point of assignment. 


>             Another related need would be the provision of an inquiry intrinsic function that would develop a list of the names of all pointers that point to a particular object.  A somewhat whimsical name could be, What_Pointers_are_Pointing_at_Me().

It could be argued that the real problem in the example is the use of raw pointers. Some object-oriented programming experts would argue that all pointers should be wrapped in a class that provides reference counting (see http://dl.acm.org/citation.cfm?id=1985786 <http://dl.acm.org/citation.cfm?id=1985786> and http://prod.sandia.gov/techlib/access-control.cgi/2010/102234.pdf <http://prod.sandia.gov/techlib/access-control.cgi/2010/102234.pdf>).   Such a class could be defined by the end user or provided by the language.  In either case, it would presumably be straightforward to also provide the What_Pointers_are_Pointing_at_Me() function.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150415/b3511791/attachment.html 

More information about the J3 mailing list