[swift-dev] How does a standard collection know when its storage has to die?

2017-10-25 Thread Daryle Walker via swift-dev
OK, so the standard collections (Array, Set, Dictionary) are value types with remote storage. Since they don’t have de-initializers, how would any reference count get any notification to eventually de-allocate ? Or is the memory leaked? Or is some sort of secret system-provided de-initalizer add

Re: [swift-dev] How does a standard collection know when its storage has to die?

2017-10-25 Thread Slava Pestov via swift-dev
These types are essentially single-field structs. The underlying storage is referenced from this field, which has a reference type. While structs cannot have user-defined destructors, the compiler knows when a value of struct type goes out of scope and destroys its fields, which for reference ty