<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="">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 </div><div class=""><br class=""></div><div class=""><b class="">AutoreleasingUnsafeMutablePointer<T?>?</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 func scanString(_ string: String, into result: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool</b></div><div class=""><br class=""></div><div class="">would become</div><div class=""><br class=""></div><div class=""><b class="">open func scanString(_ string: String, into result: inout String?) -> 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: &string)</b></div><div class=""><br class=""></div><div class="">because inout parameters require a &</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) -> 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. </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 class=""><br class=""></div><div class=""><br class=""></div></body></html>