On 27 October 2017 at 00:45, Howard Lovatt <[email protected]> wrote:
> Rather than expand local function syntax why not deprecate local functions
> completely
>
a cautious +0.5. local functions do not add that much value as one would
hope and beyond what's already discussed above, unfortunately break one
major programming guideline: "keep functions short" (*). the following two
fragments are not too different:
<<<<<<<<<<<<<<
func foo() {
let animations = {
self.view.alpha = 0.5 // self needed
}
UIView.animate(withDuration: 1, animations: animations) {
self.variable = 1 // self needed
print("completed")
}
}
==============
func foo() {
func animations() {
view.alpha = 0.5 // can do without self...
}
func completion(_ : Bool) {
variable = 1 // can do without self...
print("completed")
}
UIView.animate(withDuration: 1, animations: animations, completion:
completion)
}
>>>>>>>>>>>>>>>
(*) - closures break the "keep functions short" guideline as well :)
Mike
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution