Post

Replies

Boosts

Views

Activity

Comment on object lifetimes in swift
Ok, I understand now why the 'temporary' gets a deinit() call before I would like it to. What I still don't get, is why the same thing isn't happening when it is put inside a var, as that var is also no longer being referenced, at what seems to me to be the exact same point in the code. Is this a 'lucky coincidence', aka hidden bug, waiting to come out of hiding when some part of ARC is changed in the compiler? If there is no exact control over the lifetime of an object in swift, how would you go about implementing the C++ concept of RAII in swift?
Apr ’22