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

Jean-Daniel mailing at xenonium.com
Fri Oct 13 16:50:02 CDT 2017



> Le 13 oct. 2017 à 23:23, Mike Kluev via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> On 13 October 2017 at 21:15, Jean-Daniel <mailing at xenonium.com <mailto:mailing at xenonium.com>> wrote:
> I don’t think this is a good idea to make discardable part of the function type.
> 
> What would fun(callback: () -> discardable Int) would means ? 
> 
> you mean this?
> 
> func foo(callback: () -> discardable Int) {
>     ...
>     let x = callback()
>     ...
>     callback() // no warning or error here
> }
> 
> Mike
> 

I mean:

func foo() -> Int { … }

func bar(callback: () -> discardable Int) { … }

bar(foo) // does it warns ?
bar({ 3 }) // does it warns ? If it does, how to avoid it ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171013/021c3d4f/attachment.html>


More information about the swift-evolution mailing list