[swift-evolution] Make non-void functions @warn_unused_result by default
2th at gmx.de
Thu Dec 17 17:09:54 CST 2015
> It is a rare case for a result of a function to be unused – and most often it's caused by programmer having too little knowledge of the API.
I don't think this is a real life problem. When you have a class with something like "append" that doesn't change the receiver but returns a new object, it could be a valuable hint, but I don't like systems which assume that their users don't know what they are doing; and if this is actually the case, you are fighting a tough battle where a little warning wont help.
Please also note that ignoring a non-void return value can be absolutely ok in many situations: One example is returning self instead of useless void, which allows to build fluent interfaces - just because Cocoa didn't adopt the concept of method chaining from Smalltalk, it is still a interesting pattern which is used by other frameworks.
Imho warnings should be reserved for things that can be dangerous, and not to educate programmers...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution