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

Dave DeLong swift at davedelong.com
Mon Oct 9 11:02:07 CDT 2017

Oooo, I really like this.

It also brings up an interesting point on the whole async discussion. Doesn’t the async apply to the return value and not the other stuff?

IE instead of:

async func getBool() → Bool

It could be:

func getBool() → async Bool


> On Oct 9, 2017, at 9:58 AM, Fil Ipe via swift-evolution <swift-evolution at swift.org> wrote:
> I find it extremely cumbersome to have to precede a function declaration with such an extensive annotation such as @discardableResult
> Now that so many functions do need this annotation to be there, our code became so ugly.
> Besides, having this annotation precede the function declaration kind of reminds me of C rather than Swift. Since in C the function declarations started by the type of the return value.
> I, therefore, think it would be much softer on the eye, and much more precise in intent, to instead precede the result of a func with a simpler and shorter @discardable annotation
> So it would be:
> func() -> @discardable Bool { } 
> Rather than: 
> @discardableResult func() -> Bool { } 
> It could be even better if someone could perhaps find a shorter word that is a synonym for the word "discardable", that would be as explicit in intent as the word "discardable" is in such context, yet be written with fewer characters.
> Swift regards,
> Filipe Sá.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

More information about the swift-evolution mailing list