Hello, Swift community.
The second review of SE-0395: Observability has complete and the proposal has been accepted with revision.
The second review was of a narrower proposal, that focused on the Observable
protocol and the withTracking(_:changes:)
, with some previously proposed functionality moved to Future Directions.
One of the questions of the review was whether the "marker protocol" approach was correct. Since marker protocols do not have ABI, changing this to a regular protocol would have been impossible later if it was found that the protocol needed to add requirements. Consequently, the language steering group requested that the authors investigate making it a regular protocol. The authors were able to adapt the design to a regular protocol.
Another area discussed was the meaning of observing a stuct
type. Reviewers expressed concern that the semantics of what observing a value means were unclear, and while the steering group does agree that it is possible to define them in a way that might work for some cases, this should be deferred out of this proposal and given further consideration, with room left in the ABI to introduce it later. As such, the proposal is being amended to restrict observation to classes.
Some reviewers commented on the fact that property-wrapped properties cannot be observed. The macro transform cannot currently add or remove attributes, and reviewers commented that if that feature were added for macros, or if this were a language feature implemented in the compiler, this limitation could be lifted. However, the steering group notes that adding or removing property wrappers as part of the transform would require that that transform have a full understanding of what exactly each property wrapper did (since property wrappers are defined by users). This can be contrasted with didSet
on a property, which macros can change β but the meaning of which is fixed as part of the language. The language steering group felt that this limitation does not have a readily available alternative, and that this should not hold back the acceptance of the proposal.
SE-0395 has therefore been accepted with the above modifications for Swift 5.9. The proposal text will be updated to include them.
Thanks to both the community and the proposal authors for their time on this addition to Swift.
Ben Cohen
Review Manager