[swift-evolution] Required Callback

Haravikk swift-evolution at haravikk.me
Wed Aug 17 05:31:50 CDT 2016


> On 17 Aug 2016, at 02:49, Boris Wang via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Why the callback is special ?
> 
> The compiler should has a warning for unused parameters of function.
> 
> I think this is enough. More works should be leaved for a lint tool.

Actually I think that that kind of warning should be left for linters as well; a protocol might define parameters that not all implementations use, or a type may define a method with a parameter that is intended only for future use (to avoid defining an overload later), these aren't necessarily problems.

Also, how do you want to define unused? I suppose a non-escaping closure is unused if it's never called (since it can't be stored), but that doesn't guarantee that it *will* be called, which is the point of this proposal, i.e- a non-escaping closure may be part of a loop that may not execute, which is fine since it has no requirement to be used in every call, only that it isn't stored.

So yeah, even if a warning like this could be done right, I'm not sure it replaces the case put forward for @required.


More information about the swift-evolution mailing list