On 16 August 2016 at 23:37, James Campbell <james@supmenow.com> wrote:
@noescape is a hint that the callback will only be called once and allows
compiler to optimise, we may or may not be able to combine @required
functionality into that but it looks like it was rejected for now.
@required is a compiler hint / sanity check to enforce that the callback
is actually called once by the developer. There is no focus on any compiler
enhancements other than that.
On 16 August 2016 at 23:37, James Campbell <james@supmenow.com> wrote:
@noescape is a hint that the callback will only be called once and allows
compiler to optimise, we may or may not be able to combine @required
functionality into that but it looks like it was rejected for now.
@required is a compiler hint / sanity check to enforce that the callback
is actually called once by the developer. There is no focus on any compiler
enhancements other than that.
On 16 August 2016 at 23:37, James Campbell <james@supmenow.com> wrote:
@noescape is a hint that the callback will only be called once and
allows compiler to optimise, we may or may not be able to combine @required
functionality into that but it looks like it was rejected for now.
@required is a compiler hint / sanity check to enforce that the callback
is actually called once by the developer. There is no focus on any compiler
enhancements other than that.
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.
···
On 17 Aug 2016, at 02:49, Boris Wang via swift-evolution <swift-evolution@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.
On 17 August 2016 at 11:31, Haravikk <swift-evolution@haravikk.me> wrote:
> On 17 Aug 2016, at 02:49, Boris Wang via swift-evolution < > swift-evolution@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.