<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">&lt;<a href="https://github.com/apple/swift-corelibs-foundation/blob/5f8656628c79bf4df3980efbf45dfb3eebd35766/Foundation/NSScanner.swift#L485-L487" class="">https://github.com/apple/swift-corelibs-foundation/blob/5f8656628c79bf4df3980efbf45dfb3eebd35766/Foundation/NSScanner.swift#L485-L487</a>&gt;</div><div class=""><br class=""></div><div class=""></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>/// Revised API for avoiding usage of AutoreleasingUnsafeMutablePointer and better Optional usage.</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>/// - Note: Since this API is under consideration it may be either removed or revised in the near future</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>extension Scanner {</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanInt() -&gt; Int32?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanInteger() -&gt; Int?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanLongLong() -&gt; Int64?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanUnsignedLongLong() -&gt; UInt64?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanFloat() -&gt; Float?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanDouble() -&gt; Double?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanHexInt() -&gt; UInt32?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanHexLongLong() -&gt; UInt64?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanHexFloat() -&gt; Float?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanHexDouble() -&gt; Double?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanString(string searchString: String) -&gt; String?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanCharactersFromSet(_ set: CharacterSet) -&gt; String?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanUpToString(_ string: String) -&gt; String?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; &nbsp; public func scanUpToCharactersFromSet(_ set: CharacterSet) -&gt; String?</font></div><div class=""><font face="Courier" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div class=""><br class=""></div><div class="">Foundation issues should be discussed on the <b class="">swift-corelibs-dev</b> list.</div><div class=""><br class=""></div><div class="">-- Ben</div></div><br class=""><div><blockquote type="cite" class=""><div class="">On 30 Nov 2016, at 10:10, Oliver Drobnik 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Working on a function for Foundation’s Scanner I stumbled on this LLVM crash: <a href="https://bugs.swift.org/browse/SR-3295" class="">https://bugs.swift.org/browse/SR-3295</a><div class=""><br class=""></div><div class="">This got me thinking about a workaround and I would like to prose this:</div><div class=""><br class=""></div><div class="">When importing Foundation into Swift 3, all&nbsp;</div><div class=""><br class=""></div><div class=""><b class="">AutoreleasingUnsafeMutablePointer&lt;T?&gt;?</b></div><div class=""><br class=""></div><div class="">should instead be exposed as simple:</div><div class=""><br class=""></div><div class=""><b class="">inout T?</b></div><div class=""><br class=""></div><div class="">e.g.</div><div class=""><br class=""></div><div class=""><b class="">open&nbsp;func&nbsp;scanString(_&nbsp;string:&nbsp;String, into result:&nbsp;AutoreleasingUnsafeMutablePointer&lt;NSString?&gt;?) -&gt;&nbsp;Bool</b></div><div class=""><br class=""></div><div class="">would become</div><div class=""><br class=""></div><div class=""><b class="">open&nbsp;func&nbsp;scanString(_&nbsp;string:&nbsp;String, into result:&nbsp;inout&nbsp;String?) -&gt;&nbsp;Bool</b></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The call would stay exactly the same for normal use cases where you specify a receiving variable:</div><div class=""><br class=""></div><div class=""><b class="">var string: String?</b></div><div class=""><b class="">scanString("=", into: &amp;string)</b></div><div class=""><br class=""></div><div class="">because inout parameters require a &amp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">for the use case where you don’t require a receiving parameter, a second method without result parameter would be generated:</div><div class=""><br class=""></div><div class=""><b class="">open func scanString(_ string: String) -&gt; Bool</b></div><div class=""><br class=""></div><div class="">This is necessary because you cannot specify nil or an immutable value for an inout parameter.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">A fixit/migration would change calls to</div><div class=""><br class=""></div><div class=""><b class="">scanString(“foo", into result: nil)</b></div><div class=""><br class=""></div><div class="">into</div><div class=""><br class=""></div><div class=""><b class="">scanString(“foo")</b></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The normal call with receiving variable would stay the same. But the case without return would become more concise.</div><div class=""><br class=""></div><div class="">What do you think?</div><div class=""><br class=""></div><div class="">kind regards</div><div class="">Oliver Drobnik</div></div></div></blockquote></div></body></html>