You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team have been discussing the idea of requiring a specific entry in a closure's capture list in order to close over any reference-typed instance. This may be considered onerous but we liked the idea for its explicit documentary nature: I present it here for comment and consideration.
A slight variation on this that I think would work would be to make all references weak by default, while requiring the user to enforce a strong reference.
In this case, self is explicitly held, and another developer coming across this code can see clear intent. Further, any implicitly made weak reference, such as session in this scenario, would also have the explicit ? enforced by the compiler.
In that sense, there is a cue to reader in all cases what is happening, and helps the code become more self-documenting, and likely reducing rates of accidental retain cycles.
Additional Detail from JIRA
md5: c3a3d67f0204fffc29c85b9c6b9757f6
Issue Description:
My team have been discussing the idea of requiring a specific entry in a closure's capture list in order to close over any reference-typed instance. This may be considered onerous but we liked the idea for its explicit documentary nature: I present it here for comment and consideration.
For example:
might become
or similar.
The text was updated successfully, but these errors were encountered: