IssueRaiser

One thing I've found frustrating with Swift, and that we've had to deal with in libs we've built, is that there is an unavoidable boilerp...

One thing I've found frustrating with Swift, and that we've had to deal with in libs we've built, is that there is an unavoidable boilerplate of placing an `[unowned self]` at the top of your callbacks (e.g. `map` in the linked framework), or else you introduce a reference cycle. If you forget this `[unowned self]`, which is very easy to do, everything compiles fine and now you have a subtle memory issue to track down. I wish there was a language construct to allow you to define closures that have every captured variable unowned (or weak) by default. I would, at the very least, emphasize somewhere in your docs with big bold letters how important it is to add the boilerplate, or users of Bond will definitely get bitten by this.

Posted by wxs on Jan 30, 2015, 4:43 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.8,000 issues0 comments

reliability (Other)

One thing I've found frustrating with Swift, and that we've had to deal with in libs we've built, is that there is an unavoidable boilerp...

wxsJan 30, 2015, 4:43 PM

One thing I've found frustrating with Swift, and that we've had to deal with in libs we've built, is that there is an unavoidable boilerplate of placing an `[unowned self]` at the top of your callbacks (e.g. `map` in the linked framework), or else you introduce a reference cycle. If you forget this `[unowned self]`, which is very easy to do, everything compiles fine and now you have a subtle memory issue to track down. I wish there was a language construct to allow you to define closures that have every captured variable unowned (or weak) by default. I would, at the very least, emphasize somewhere in your docs with big bold letters how important it is to add the boilerplate, or users of Bond will definitely get bitten by this.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue