<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thank you Dmitri for your feedback. Updated draft below.</div><div class=""><br class=""></div><a href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md" class="">https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md</a><div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; font-size: 32px; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.5; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255); margin-top: 0px !important;" class="">Remove&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;and replace&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;by&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe</code></h1><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><li style="box-sizing: border-box;" class="">Proposal:&nbsp;<a href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none;" class="">SE-0000</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Author:&nbsp;<a href="https://github.com/aschwaighofer" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none;" class="">Arnold Schwaighofer</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Status:&nbsp;<span style="box-sizing: border-box; font-weight: 600;" class="">Pitch</span></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Review manager: TBD</li></ul><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-introduction" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#introduction" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Introduction</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Remove&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;and replace&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced&lt;T: NonObjectiveCBase&gt;(_ object: T)</code>&nbsp;by<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe&lt;T: AnyObject&gt;(_ object: T)</code>. This will remove surface API. Instead of a type check dynamically check the non-<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">@objc</code>&nbsp;constraint under&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">-Onone</code>.</p><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><li style="box-sizing: border-box;" class="">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160711/024515.html" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none;" class="">Pitch</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Swift bug:&nbsp;<a href="http://bugs.swift.org/browse/SR-1962" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none;" class="">SR-1962</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Branch with change to stdlib:&nbsp;<a href="https://github.com/aschwaighofer/swift/tree/remove_nonobjectivecbase" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none;" class="">remove_nonobjectivecbase</a></li></ul><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-motivation" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#motivation" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Motivation</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Today we have&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;which only works on subclasses of NonObjectiveCBase, and we have&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedNonObjC</code>&nbsp;which also works on&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">@objc</code>&nbsp;classes.</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> SwiftKlazz <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">NonObjectiveCBase</span> {}
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> ObjcKlazz <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> NSObject {}

expectTrue(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">isUniquelyReferenced</span>(SwiftKlazz()))
expectFalse(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">isUniquelyReferencedNonObjC</span>(ObjcKlazz()))

<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Would not compile:</span>
expectFalse(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">isUniquelyReferenced</span>(ObjcKlazz()))</pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">In most cases we expect developers to be using the ManagedBufferPointer type. In cases where they want to use a custom class they would use&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;today and can use&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe</code>&nbsp;in the future.</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> SwiftKlazz <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">NonObjectiveCBase</span> {}
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> ObjcKlazz <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> NSObject {}

expectTrue(isUniquelyReferencedUnsafe(SwiftKlazz()))
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Would trap under -Onone:</span>
expectFalse(isUniquelyReferencedUnsafe(ObjcKlazz()))</pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Replacing&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced&lt;T : NonObjectiveCBase&gt;</code>&nbsp;by&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe&lt;T: AnyObject&gt;</code>&nbsp;will allow us to remove the&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;class from the standard library thereby shrink API surface. We argue that trading type safety for less API surface is a good trade-off to make with this low-level API.</p><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-proposed-solution" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#proposed-solution" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Proposed solution</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Replace&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced&lt;T : NonObjectiveCBase&gt;</code>&nbsp;by&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe&lt;T: AnyObject&gt;</code>&nbsp;and remove the&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;class from the standard library.</p><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-detailed-design" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#detailed-design" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Detailed design</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Todays APIs that can be used to check uniqueness is the family of&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;functions.</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns `true` iff `object` is a non-`@objc` class instance with</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// a single strong reference.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// * Does *not* modify `object`; the use of `inout` is an</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   implementation artifact.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// * If `object` is an Objective-C class instance, returns `false`.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// * Weak references do not affect the result of this function.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Useful for implementing the copy-on-write optimization for the</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// deep storage of value types:</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///     mutating func modifyMe(_ arg: X) {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       if isUniquelyReferencedNonObjC(&amp;myStorage) {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///         myStorage.modifyInPlace(arg)</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       }</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       else {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///         myStorage = self.createModified(myStorage, arg)</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       }</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///     }</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">isUniquelyReferencedNonObjC</span>&lt;T <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyObject</span>&gt;(<span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">_</span> <span class="pl-smi" style="box-sizing: border-box;">object</span>: <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">inout</span> <span class="pl-smi" style="box-sizing: border-box;">T</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">isUniquelyReferencedNonObjC</span>&lt;T <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyObject</span>&gt;(<span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">_</span> <span class="pl-smi" style="box-sizing: border-box;">object</span>: <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">inout</span> <span class="pl-smi" style="box-sizing: border-box;">T</span>?) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>

<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// A common base class for classes that need to be non-`@objc`,</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// recognizably in the type system.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">NonObjectiveCBase</span> {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">init</span>() {}
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">isUniquelyReferenced</span>&lt;T <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">NonObjectiveCBase</span>&gt;(
  <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">_</span> <span class="pl-smi" style="box-sizing: border-box;">object</span>: <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">inout</span> <span class="pl-smi" style="box-sizing: border-box;">T</span>
) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span></pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">And the somewhat higher level APIs that can be used to model a storage with several elements&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ManagedBufferPointer</code>.</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Contains a buffer object, and provides access to an instance of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `Header` and contiguous storage for an arbitrary number of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `Element` instances stored in that buffer.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// For most purposes, the `ManagedBuffer` class works fine for this</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// purpose, and can simply be used on its own.  However, in cases</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// where objects of various different classes must serve as storage,</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `ManagedBufferPointer` is needed.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// A valid buffer class is non-`@objc`, with no declared stored</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   properties.  Its `deinit` must destroy its</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   stored `Header` and any constructed `Element`s.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `Header` and contiguous storage for an arbitrary number of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `Element` instances stored in that buffer.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedBufferPointer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Equatable</span> {
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Create with new storage containing an initial `Header` and space</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// for at least `minimumCapacity` `element`s.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// - parameter bufferClass: The class of the object used for storage.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// - parameter minimumCapacity: The minimum number of `Element`s that</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   must be able to be stored in the new buffer.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// - parameter initialHeader: A function that produces the initial</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   `Header` instance stored in the buffer, given the `buffer`</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   object and a function that can be called on it to get the actual</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   number of allocated elements.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// - Precondition: `minimumCapacity &gt;= 0`, and the type indicated by</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   `bufferClass` is a non-`@objc` class with no declared stored</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   properties.  The `deinit` of `bufferClass` must destroy its</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   stored `Header` and any constructed `Element`s.</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">init</span>(
    bufferClass: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyClass</span>,
    minimumCapacity: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>,
    initialHeader: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">@noescape</span> (buffer: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyObject</span>, capacity: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">@noescape</span> (<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyObject</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">throws</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> Header
  ) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">rethrows</span>

  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns `true` iff `self` holds the only strong reference to its buffer.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// See `isUniquelyReferenced` for details.</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">mutating</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">holdsUniqueReference</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>

  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns `true` iff either `self` holds the only strong reference</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// to its buffer or the pinned has been 'pinned'.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// See `isUniquelyReferenced` for details.</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">mutating</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">holdsUniqueOrPinnedReference</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>

  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">internal</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> _nativeBuffer: Builtin<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>NativeObject
}

<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// A class whose instances contain a property of type `Header` and raw</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// storage for an array of `Element`, whose size is determined at</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// instance creation.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedProtoBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span> {

  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Create a new instance of the most-derived class, calling</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `initialHeader` on the partially-constructed object to</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// generate an initial `Header`.</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">final</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">class</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">create</span>(
    minimumCapacity: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>,
    initialHeader: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">@noescape</span> (<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedProtoBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>) throws <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> Header
  ) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">rethrows</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span> {

    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> p <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">try</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedBufferPointer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;</span>(
      bufferClass: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span>,
      minimumCapacity: minimumCapacity,
      initialHeader: { buffer, _ <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">in</span>
        <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">try</span> initialHeader(
          <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">unsafeDowncast</span>(buffer, to: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedProtoBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span>))
      })

    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">unsafeDowncast</span>(p<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">buffer</span>, to: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ManagedBuffer</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&lt;</span>Header, Element<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&gt;.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span>)
  }
}
</pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">We propose to remove the&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;class and change&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced&lt;T: NonObjectiveCBase&gt;(_ object: T&gt;</code>&nbsp;to:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns `true` iff `object` is a non-`@objc` class instance with a single</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// strong reference. `object` is assumed to be a non-`@objc` class instance.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// In debug mode this function will check this assumption. Otherwise, it is</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// undefined what happens.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// * Does *not* modify `object`; the use of `inout` is an</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///   implementation artifact.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// * Weak references do not affect the result of this function.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Useful for implementing the copy-on-write optimization for the</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// deep storage of value types:</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///     mutating func modifyMe(_ arg: X) {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       if isUniquelyReferencedUnsafe(&amp;myStorage) {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///         myStorage.modifyInPlace(arg)</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       }</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       else {</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///         myStorage = myStorage.createModified(arg)</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///       }</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///     }</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// This function is safe to use for `mutating` functions in</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// multithreaded code because a false positive would imply that there</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// is already a user-level data race on the value being mutated.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">isUniquelyReferencedUnsafe</span>&lt;T <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">AnyObject</span>&gt;(
  <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">_</span> <span class="pl-smi" style="box-sizing: border-box;">object</span>: <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">inout</span> <span class="pl-smi" style="box-sizing: border-box;">T</span>
) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span> {
  _debugPrecondition(
    _usesNativeSwiftReferenceCounting(object<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">dynamicType</span>),
    <span class="pl-s" style="box-sizing: border-box; color: rgb(24, 54, 145);"><span class="pl-pds" style="box-sizing: border-box;">"</span>instance must be a non-@objc class instance<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> _isUnique(<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">&amp;</span>object)
}</pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Note, that today at -O we would actually not cause undefined behavior but rather just return false. We don't want to guarantee this in the future so the comment specifies undefined behavior.</p><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-impact-on-existing-code" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#impact-on-existing-code" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Impact on existing code</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Existing code that uses&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;will need to remove the&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">NonObjectiveCBase</code>&nbsp;base class and replace calls to&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferenced</code>&nbsp;by&nbsp;<code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">isUniquelyReferencedUnsafe</code>. The old API will be marked unavailable to help migration.</p><h2 style="box-sizing: border-box; margin-top: 1em; margin-bottom: 16px; line-height: 1.5; font-size: 24px; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-alternatives-considered" class="anchor" href="https://github.com/aschwaighofer/swift-evolution/blob/remove_nonobjectivecbase/proposals/0000-remove-nonobjectivecbase.md#alternatives-considered" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Alternatives considered</h2><div style="box-sizing: border-box; margin-top: 0px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255); margin-bottom: 0px !important;" class="">Leave the status quo and pay for type safety with additional API surface.</div></div><div style="box-sizing: border-box; margin-top: 0px; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255); margin-bottom: 0px !important;" class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class="">On Jul 16, 2016, at 1:21 PM, Dmitri Gribenko &lt;gribozavr@gmail.com&gt; wrote:<br class=""><br class="">For presentation and clarity, could you show the full family of<br class="">`isUniquely*` functions in the design section, including those<br class="">functions that you are not proposing to change? &nbsp;This will make it<br class="">easier to see what choices users will get. &nbsp;It would be also great to<br class="">include the API of similar ManagedBuffer and ManagedBufferPointer<br class="">APIs, if any exist.<br class=""><br class="">Dmitri<br class=""><br class="">--&nbsp;<br class="">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;gribozavr@gmail.com&gt;*/<br class=""></blockquote><br class=""></div></body></html>