-
Notifications
You must be signed in to change notification settings - Fork 11
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
Rethink memory management (construction/destruction) #138
Comments
Another alternative is keeping the current "objects are pointers" paradigm and adding a |
My two cents - here's the behavior I think I'd like, though I get that this is a difficult needle to thread. Sorry, this is a bit stream-of-consciousness:
Then add a separate opt-in capability for reference counted (shared_ptr) semantics that makes assignment safe. If you want "safe" references to a proxy object for the default case, I think the most universal option that supports both creating refs to objects owned in Fortran and refs to objects owned in C++ is to define separate |
(To be honest, I've probably held every possible position under the sun about what the right way to design resource-owning classes in Fortran is. It would be a lot easier if Fortran had move semantics) |
I can respond more in detail later, but one the important historical note is that during most of the development of SWIG-Fortran's semantics, Gfortran's |
Hm... I've been happily using finalizers in GCC 7, but it's possible I haven't hit the corner cases where they're broken. It would be a good optional feature, nonetheless. |
Currently, instantiating and cleaning up classes is done in a very C++-like manner, with a constructor statement and a
release
statement. Assignment of proxy class objects generally acts like pointer association (=>
in Fortran)which prohibits assignment of class data; so the following can't be used to change the contents of the vector:
Is there a way to allocate, assign, point to, and deallocate with SWIG proxy types? Can we make it at least as safe as the current method, and as safe as native Fortran?
For example, something like
I don't think that native Fortran pointers are reference-counted, so I'm not sure how to safely obtain a C++ reference and make it appear as a Fortran pointer.
The text was updated successfully, but these errors were encountered: