(j3.2006) Frustrating consequence of F2003 allocation semantics
Wed Apr 15 09:02:03 EDT 2015
On Apr 15, 2015, at 7:34 AM, Tom Clune <Thomas.L.Clune at nasa.gov> wrote:
>>> 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 and 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.
If the interest is in a list of pointers that are associated with a target, then the magic wrapper class would need to be for the target.
> Well ? if you are talking about _strings_ that name those pointers, that would not be possible in practice due to nested data structures. If you are talking about just the pointers, it would be an amusing list - they would all be the ?same? in any sense detectable by Fortran.
I was assuming that all of the name information would have been stored somewhere inside the magic wrapper class. Although this would be an interesting implementation problem since the names of variables are lost by execution time. Maybe a database correlating addresses and scopes with names could be kept. Note that the ?name? is potentially confusing - is it a dummy argument name or the name of the effective argument (or ultimate argument)? Certainly not something I would want specified in the language standard, but an interesting exercise for the user. And definitely a useful feature for a debugger.
> I think by the time a developer thought to check such a list (at run time?), she could have simply used ?buffer(:) = ??
And end up with much better performing code in the process. While continued evolution to keep up with hardware realities is important, we should not forget that Fortran?s long existence is substantially tied to good performance of the executable code.
> I suspect you both are thinking of the former (string name), but not only does it imply dark corners that are problematic, it would be a big stretch for the language to provide that degree of introspection. (Though - I would love to have a standard mechanism to associate a name-string with any variable/procedure - probably with a few associated intrinsics for stripping of modules, name mangling and so on. Not holding my breath for that though.)
Bill Long longb at cray.com
Fortran Technical Suport & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
More information about the J3