Michael Tsai – Blog – Swift Proposal: weak let


SE 0481:

Currently, Swift classes with weak stored properties cannot be Sendable, because weak properties have to be mutable, and mutable properties are not allowed in Sendable classes[…]

[…]

In fact, wrapping weak references in a single-property struct is a viable workaround to the var restriction in both properties and captures[…] The existence of this simple workaround is itself an argument that the prohibition of weak let is not enforcing some fundamentally important rule.

[…]

An explicit weak capture is now immutable under this proposal, like any other explicit capture. If the programmer really needs a mutable capture, they must capture a separate weak var.


1 Comment


We will be happy to hear your thoughts

Leave a reply

Som2ny Network
Logo
Compare items
  • Total (0)
Compare
0