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

Félix Cloutier felixcca at yahoo.ca
Mon Jan 4 12:49:04 CST 2016


I like this syntax, but I don't like that it could be ambiguous with successively calling animateWithDuration then some function called completion.

Other than that, I think that developers should be smart enough to exercise self-restraint with trailing closures when they're not appropriate. I don't understand what you (QQ Mail) mean with "you have to write it manually".

Félix

> Le 4 janv. 2016 à 12:50:15, Michel Fortin via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> Le 4 janv. 2016 à 7:45, QQ Mail via swift-evolution <swift-evolution at swift.org> a écrit :
>> I would like to write like this: 
>> 
>> UIView.animateWithDuration(0.3,
>> 
>>    animations: { () -> Void in
>>        // animation code here
>>    },
>>    completion: { Bool -> Void in
>>        // completion code here
>>    }
>> )
> 
> Maybe, instead of disallowing trailing closures, we could allow consecutive closures to be expressed like that:
> 
> UIView.animateWithDuration(0.3) {
> 	// animation code here
> } completion { success in
> 	// completion code here
> }
> 
> -- 
> Michel Fortin
> https://michelf.ca
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list