[swift-evolution] [Proposal] Remove force unwrapping in function signature.

Adrian Zubarev adrian.zubarev at devandartist.com
Sat Jun 11 09:44:35 CDT 2016


Yes please, current Swift 3 Snapshot translated a lot of C functions from not optionals to optionals just because let and var works correctly on UnsafeMutablePointer’s.

This is confusing and ugly:

public func freeaddrinfo(_: UnsafeMutablePointer<addrinfo>!)
public func gai_strerror(_: Int32) -> UnsafePointer<Int8>!
public func getaddrinfo(_: UnsafePointer<Int8>!, _: UnsafePointer<Int8>!, _: UnsafePointer<addrinfo>!, _: UnsafeMutablePointer<UnsafeMutablePointer<addrinfo>?>!) -> Int32
public func gethostbyaddr(_: UnsafePointer<Swift.Void>!, _: socklen_t, _: Int32) -> UnsafeMutablePointer<hostent>!
public func gethostbyname(_: UnsafePointer<Int8>!) -> UnsafeMutablePointer<hostent>!
public func gethostent() -> UnsafeMutablePointer<hostent>!
public func getnameinfo(_: UnsafePointer<sockaddr>!, _: socklen_t, _: UnsafeMutablePointer<Int8>!, _: socklen_t, _: UnsafeMutablePointer<Int8>!, _: socklen_t, _: Int32) -> Int32
public func getnetbyaddr(_: UInt32, _: Int32) -> UnsafeMutablePointer<netent>!
public func getnetbyname(_: UnsafePointer<Int8>!) -> UnsafeMutablePointer<netent>!
public func getnetent() -> UnsafeMutablePointer<netent>!
public func getprotobyname(_: UnsafePointer<Int8>!) -> UnsafeMutablePointer<protoent>!
public func getprotobynumber(_: Int32) -> UnsafeMutablePointer<protoent>!
public func getprotoent() -> UnsafeMutablePointer<protoent>!
public func getservbyname(_: UnsafePointer<Int8>!, _: UnsafePointer<Int8>!) -> UnsafeMutablePointer<servent>!
public func getservbyport(_: Int32, _: UnsafePointer<Int8>!) -> UnsafeMutablePointer<servent>!
public func getservent() -> UnsafeMutablePointer<servent>!
Look at this mess!



-- 
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160611/660a015d/attachment.html>


More information about the swift-evolution mailing list