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

Xiaodi Wu xiaodi.wu at gmail.com
Thu Oct 19 10:22:02 CDT 2017


On Thu, Oct 19, 2017 at 08:59 Mike Kluev <mike.kluev at gmail.com> wrote:

> On 19 October 2017 at 08:52, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
>> No, I'm talking about the implicit discardability proposed by Brent, such
>> as for all Optional<@discardable T>.
>>
>> He proposes that the @discardable syntax has a strong motivating
>> advantage because it can be extended in a way to mark _types_ so that
>> return values of those types are always implicitly @discardable. That is:
>>
>> @discardable class A { ... }
>> // any return value of type A is implicitly discardable
>> // what happens if A : Error and I throw A?
>>
>> class B : A { ... }
>> // is any return value of type B also implicitly discardable?
>
>
> "discardable" only apply to return types, similar to how "inout" only
> applies to "parameter types"
> (e.g. you can't make "func foo(x: Optional<inout Bool>)"
>

Of course. That’s not the concern.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171019/8977da27/attachment.html>


More information about the swift-evolution mailing list