Hi everybody,
I do agree with Kevin : trailing closures is only a possibility offered by
the language, you are not forced to use it.
In the case you show, I agree that the second syntax is more readable than
the first one. Good news is : it does compile :-).
I think adding a specific keyword or annotation to locally forbid trailing
closure would add complexity to the language for no real advantage.
-1 for me thus.
Jerome
On 04 Jan 2016, at 19:52, Kevin Ballard via swift-evolution < > swift-evolution@swift.org> wrote:
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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution