[swift-evolution] Make non-void functions @warn_unused_result by default
Andrey Tarantsov
andrey at tarantsov.com
Wed Mar 2 01:50:44 CST 2016
Whoa. Everyone seems to be in favor of this. Don't you guys always
return something ‘just in case’, in the best traditions of C API design?
I tend to have lots of discardable results and only a few where I might
legitimately forget to use it.
IMO, in most cases ignoring a return value is “safe”:
a) If a method is called only for its result, forgetting to use the
result won't really introduce any new bugs — if you're not using that
missing result elsewhere, storing it into a variable won't help.
b) If you're calling a method for its side effect, normally the result
may be discarded.
The only case where this matters is when the method establishes a long-
term relationship (like a subscription) that needs to be stored to
survive. That seems like a rare case.
Any other practical cases?
A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160302/a989f6ff/attachment-0001.html>
More information about the swift-evolution
mailing list