[swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}
Fil Ipe
filipesaz at gmail.com
Sat Oct 7 01:48:08 CDT 2017
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á.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171007/73ac3a38/attachment.html>
More information about the swift-evolution
mailing list