[swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}

Jean-Daniel mailing at xenonium.com
Sun Oct 15 14:59:12 CDT 2017



> Le 15 oct. 2017 à 15:52, Mike Kluev via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> On 15 October 2017 at 14:23, Geordie Jay <geojay at gmail.com <mailto:geojay at gmail.com>> wrote:
> Hi Mike,
> 
> 2017-10-15 14:55 GMT+02:00 Mike Kluev <mike.kluev at gmail.com <mailto:mike.kluev at gmail.com>>:
> On 15 October 2017 at 13:35, Geordie Jay <geojay at gmail.com <mailto:geojay at gmail.com>> wrote:
> Also we're not talking about whether the Bool itself is discardable. For example, it makes no sense to write:
> 
> let something: discardable Bool = true
> 
> you can't write this either:
> 
> let something: inout Bool = true
> 
> that doesn't mean "inout" should be "@inputOutput" before the parameter name in function signature.
> 
> This is a different case: inout is an annotation on argument types (of which there can be many).
> 
> i mean:
> 
> @discardableResult func foo(@inputOutput x: Int, @inputOutput y: Float) -> Bool 
> 
> vs:
> 
> func goo(x: inout Int, y: inout y) -> discardable Bool
> 

inout and discardableResult are fundamentally different. Inout change the calling convention and the way the parameter is passed. discardableResult is just an annotation to help catching bad function usage by warning the developer about it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171015/34c21885/attachment.html>


More information about the swift-evolution mailing list