swig-fortran / swig

This fork of SWIG creates Fortran wrapper code from C++ headers.
http://www.swig.org
Other
42 stars 11 forks source link

Make memory management more consistent #107

Closed sethrj closed 5 years ago

sethrj commented 5 years ago

Currently from the user perspective, the assignment operator works differently for smart pointers and non-smart pointers. Right now,

a = b

will, if the type is not a smart pointer:

  1. If a is uninitialized: create a "copy" [via copy constructor] of b;
  2. Otherwise, assign b's contents to a, so that existing pointers to a will also have their values updated. or if the type is a smart pointer:
  3. Make a a new shared pointer indistinguishable from b, whether or not a is assigned.

After trying @tjfulle's suggestion of "they should behave like standard fortran objects" so that assignment copies the data, I'm thinking that instead we should have them behave as derived types that hold pointers to another class. This would make it far easier to implement consistent and complete assignment semantics.

sethrj commented 5 years ago

Closed by #110