[swift-evolution] [Proposal Update 1] A simplified notation for avoiding the weak/strong dance with closure capture lists

Brent Royal-Gordon brent at architechies.com
Fri Feb 12 17:07:03 CST 2016


> guard reconstitute self else { return }

I think `reconstitute` is inferior to `let self = ` on almost every axis. It's longer, requires you to learn a new keyword instead of applying existing constructs, and doesn't solve any other problems the way permitting `self` shadowing would.

> I think it's important to defer to the programmer on how the weak self condition is handled, enabling any clean-up action to be taken as well as deciding whether to terminate the app, recover, etc.

I'm really not convinced by this by this. If you want to terminate, capture the variable `unowned`. If you want to customize the behavior in some other way, do a weak-strong dance just like today.

I'm not entirely convinced `[guard]` is a good idea either, but the lack of `else` customization isn't the reason for my concern. "Just do nothing if this doesn't exist" is by far the most common case for guarding on a weak `self`.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list