<@U3SK5B492> Were destructors ever added to Kotlin...
# kotlin-native
s
@olonho Were destructors ever added to Kotlin/native? If I have a frozen object with a reference to a C Pointer where I'm storing a mutable Kotlin object, I want to ensure that the C pointer gets cleaned up with the frozen object is free'd. Is there a way for me to do such a thing without destructors?
o
Nope, general purpose destructors are not and unlikely will get added. Moreover the whole solution you sketched looks scary 🙂. But with inline function scoped lifetimes could be emulated, like in memScope.
s
Yeah, it is scary. I was just curious if such a thing were possible in an extreme circumstance where I wanted to share an object with mutable data across threads, in a Kotlin/common scenario, and rely on Kotlin to clean it up at the proper time. Is there no way to link a C++ object and have Kotlin free the C++ object from memory at the proper time outside of a memScope?
I'm going through thought experiments of how I'll need to modify my teams Android Architecture to share code with iOS properly. I always end up needing to do too much in my UI thread, or needing to break the application in half so that there is a backend layer that runs on a background thread. Breaking things in half forces a complete separation of objects that can't be shared between the layers, and forces me to maintain 2 separate main threads. It's a bit odd.