[swift-evolution] Making capturing semantics of local
Mike Kluev
mike.kluev at gmail.com
Thu Oct 26 22:15:22 CDT 2017
On 27 October 2017 at 00:45, Howard Lovatt <howard.lovatt at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171027/b4813f56/attachment.html>
More information about the swift-evolution
mailing list