I don't think that counting discardable results in existing Cocoas libraries is 
a good metric for the usefulness of warn-unused-result: Other libraries may 
follow a different style, and Objective-C is a very bad fit for fluent 
interfaces.
So far, I haven't seen any real world examples of problems caused by 
accidentally discarded results, and changing the default would be be a real 
pain that discourages established patterns.
The imho easiest solution would be a module-specific setting for the default.

> That includes, by the way, some *stupendously* bad ideas, such as calling 
> `tryLock` without seeing if the lock succeeded. I would guess that more than 
> half of the "discardable" category are the sort of thing that would leave you 
> gaping at the screen if you saw them in a piece of code.
I see this as a strong argument to only slightly modify the current behavior:
- Add a @pure-annotation which implies warn-unused-result
- Change the name/syntax of warn-unused-result to something shorter and less 
ugly (already discussed, but no proposals yet)

When nearly all functions trigger warnings, it becomes harder to spot the cases 
where it is really likely that someone made an error by ignoring a result.

Tino
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to