<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPhone</div><div><br>On Jul 16, 2016, at 8:45 PM, Andrew Trick &lt;<a href="mailto:atrick@apple.com">atrick@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 16, 2016, at 8:36 PM, Arnold &lt;<a href="mailto:aschwaighofer@apple.com" class="">aschwaighofer@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Thank you for the feedback. Answers online.<br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On Jul 16, 2016, at 7:38 PM, Andrew Trick &lt;<a href="mailto:atrick@apple.com" class="">atrick@apple.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 16, 2016, at 6:46 PM, Arnold Schwaighofer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><p class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; 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);">Replace&nbsp;<code class="" 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;">isUniquelyReferenced&lt;T : NonObjectiveCBase&gt;</code>&nbsp;by&nbsp;<code class="" 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;">isUniquelyReferencedUnsafe&lt;T: AnyObject&gt;</code>&nbsp;and remove the&nbsp;<code class="" 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;">NonObjectiveCBase</code>&nbsp;class from the standard library.</p><div class=""><br class=""></div></div></blockquote><br class=""></div><div class="">So we’ll have:</div><div class=""><br class=""></div><div class="">- isUniquelyReferencedNonObjC(object): true iff object is uniquely referenced and NonObjC</div><div class=""><br class=""></div><div class="">- isUniquelyReferencedUnsafe(object): true iff object is uniquely reference, assert NonObjC</div><div class=""><br class=""></div><div class="">I’m going to be picky. The “Unsafe” suffix doesn’t make sense to me. If you think this is an unsafe API then it should be:</div><div class="">“unsafeIsUniquelyReferenced”.</div><div class=""><br class=""></div><div class="">But I don’t really see how it is unsafe in the usual sense. If you want to convey that the programmer needs to satisfy some precondition, which is not generally associated with unsafety, then it should be:</div><div class="">“isUniquelyReferencedAssumingNonObjC”</div><div class=""><br class=""></div></div></blockquote><div class=""><br class=""></div>Makes sense to me. I think it is unsafe in the sense if you don't satisfy the precondition the resulting behavior is undefined in modes other than -Onone and not checked by a precondition predicate that traps.<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><font class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">unsafeIsUniquelyReferenced</span></font></blockquote><br class=""></div><div class="">I find it kind of nice to recognize a predicate by the 'is' prefix. All unsafe APIs start with the word unsafe though. I could not find an unsafe freestanding predicate.<br class=""><div class=""><br class=""></div><div class=""><div class=""><div class=""><div class="">[As the implementor of the underlying builtin you may remember that it is not actually undefined and will return a implementation defined value (false) for objc classes. But we might not want to guarantee this going forward.]</div></div></div></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">Oh yeah. I think I only kept the two versions for fear of breaking the API. Since you’re renaming the second one anyway, why not just delete it with a fixit that it's renamed to isUniquelyReferencedNonObjC?</div><div class=""><br class=""></div><div class="">The “assuming” version of the API is extremely confusing in addition to being useless.</div></blockquote><br><div>The unsafe version would allow us to emit more efficient code (in the future) for a static unknown object type but we know it is a native type (but not which so we can't just cast it, this is public API so we can't cast to Builtin.NativeObject).</div><div><br></div><div>&nbsp; var self: AnyObject // really: AnyNativeObject</div><div>&nbsp; ...</div><div>&nbsp; if (!unsafeIsUniquelyReferenced(&amp;self))</div><div>&nbsp; &nbsp; self = self.copy()</div><div>&nbsp; }</div><div><br></div><div>I admit this is somewhat contrived and am happy to just nuke the API if we agree there is no value in the use case above.</div></body></html>