[swift-evolution] [Proposal]: support disable to trailing closure syntax

Kevin Ballard kevin at sb.org
Mon Jan 4 12:52:55 CST 2016


What's the point of this? What problem does it solve? If you don't want
a trailing closure, just don't use trailing closure syntax. I don't see
what benefit there is in explicitly annotating the function to disallow
trailing closure syntax with it; just because you don't want to use
trailing closure syntax doesn't mean nobody should be able to use it.
And other people using it shouldn't affect you.

-Kevin Ballard

On Mon, Jan 4, 2016, at 04:45 AM, QQ Mail via swift-evolution wrote:
> Hi, All: trailing closure is good for most cases, but sometimes it is
> also make code unclear, for example:
>
> UIView.animateWithDuration(0.3, animations: { () -> Void in //
> animation code here    }) { (Bool) -> Void in // completion
> code here }
>
> the label been removed and the code also not aligned well. I would
> like to write like this:
>
> UIView.animateWithDuration(0.3,
>


> animations: { () -> Void in // animation code here    },
> completion: { Bool -> Void in // completion code here    } )
>
> It is possible, just every time you have to write it manually. It’s a
> little wast. So I have a thought, since we already know this function
> is not well suit for trailing closure, can we add a attribute to
> disable it, for example:
>
> extensionUIView {
>
> @disable_trailing_closure    public static func
> animateWithDuration(duration:NSTimeInterval, animations:()->Void, completion:()-
> >Void) { // implementations ...    } }
>
> I also found another one have issue for this too. link:
> http://www.natashatherobot.com/swift-trailing-closure-syntax/ what do
> you think?
>
> Best Regards
>
> ChenYungui
>
> _________________________________________________
> swift-evolution mailing list swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160104/bf482150/attachment.html>


More information about the swift-evolution mailing list