+1 to the guarded closures proposal. This would streamline syntax and offer an easy way to bypass a large set of retain cycle issues.
I'd be more hesitant on the @guarded
attribute. The decision of how to capture values in a closure, including self
, seems like it should be made at the point of use rather than in the API declaration. What use cases do you have in mind for this?
On a tangential note -- would it be a good time to revisit this discussion (removing the explicit self
requirement in closures when self
is included in the capture list)? It picked up a good bit of support, but looks like it was forgotten. Might be worth revisiting, in the light of this proposal and other discussions on rebinding self
in closures.