<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 10, 2016, at 4:31 AM, Austin Zheng via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Mark-and-sweep GC seems to be a non-starter as long as Swift's collections remain copy-on-write value types. The way an Array (or other dynamically sized stdlib collection) knows to write to its existing buffer, rather than creating a whole new copy, is by looking at the buffer object's reference count (via the `isUniquelyReferenced` API). Mike Ash has a good summary of how this process works here: <a href="https://www.mikeash.com/pyblog/friday-qa-2015-04-17-lets-build-swiftarray.html" class="">https://www.mikeash.com/pyblog/friday-qa-2015-04-17-lets-build-swiftarray.html</a>.<div class=""><br class=""></div><div class="">The RemObjects Silver Swift-alike compiler, which targets the JVM and CLR, is forced to treat its collections as reference types because of how COW is implemented: <a href="http://docs.elementscompiler.com/Silver/DifferencesAndLimitations/" class="">http://docs.elementscompiler.com/Silver/DifferencesAndLimitations/</a>.</div><div class=""><br class=""></div><div class="">The most pertinent questions with regards to Swift GC are: whether or not some acceptably efficient form of efficient copy-on-write mechanism for value type collections in a tracing GC environment exists, and if not whether the enormous semantic change that turning collections into reference types would entail would be worthwhile. (This in turn would have a whole set of knock-on effects; for example, generic stdlib collections could no longer be properly covariant.)</div></div></div></blockquote><br class=""></div><div>It's within the realm of possibility to have a hybrid approach, where value type buffers have reference counts maintained by compiler-inserted retain/release operations when semantic copies occur in an otherwise GC environment.</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>