-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference counted pointer #334
Comments
It will be interesting to study the response(s) from J3/WG5 on this, especially from /DATA subgroup if at all this advances to their attention. My hunch is this will die on the vine. @certik, please refer back to your own post (link) at the Discourse site you cite in the original post here re: the cost of adding new features of the language. If features are first seen as a cost, how do you think this can ever be introduced? The use case for such a feature is somewhat better convenience for the programmer and - perhaps - reduced vulnerability primarily when a derived type ( a class in OO parlance) with type-bound procedures (that is a detailed OO-approach) is employed for data management. This is all good in my own personal opinion but most readers and also those who have votes on standard committee(s) have been opponents to features with such use cases, again your own point often about "costs" and bloated language, etc. help boost the opposition, So what exactly changes here? |
Beyond the need expressed in this thread, such pointers would help for a safer programming by avoiding memory leaks. |
What would count as a "reference" that would change an object's reference count? Dummy argument association? Construct association? Pointer assignment? Or only new take/drop operations? |
Reference counting makes more sense with allocatables than pointers, actually. A new |
I'm not sure it is as flexible as desired (unless |
The shareable allocatables would have to bear a new distinguishing attribute ( |
Thanks @klausler for the feedback. Yes, I think this can be done relatively nicely. We would need to prototype in a compiler to iron out the details. @FortranFan yes, every feature should be weighted against the costs. That is best done after implementing in a compiler and testing the feature. I don't know if it is worth doing or not, but I like that we can use this proposals repository to freely discuss any feature and see how it would fit into the language and if there is enough interest in it. And just reference the issue in future discussions. |
I was rather thinking about something inspired by
EDIT: not a good idea overall, as it would allow too many cases that would just look "safe" but wouldn't be safe at all... |
I'd need to see a prototype for that. |
@klausler would such approach facilitate managing C interoperability of a Fortran DT (containing allocatables instead of pointers) with C/Python structs? I ask because a consequence of the design mentioned in the thread on Discourse was that binding the pointer arrays for interoperability became transparent with |
Fortran has a non-owning
pointer
and an owningallocatable
. In some cases also having a reference counted pointer (likestd::shared_ptr
in C++, or like the classes work in Python) would be helpful.This has been requested a few times, some relevant past discussion:
The text was updated successfully, but these errors were encountered: