Async non-mutating setters

Despite this paragraph in SE-0296, it looks like properties with async getter are supported in the end, with Task.value as an obvious example.

Rationale : Properties and subscripts that only have a getter could potentially be async . However, properties and subscripts that also have an async setter imply the ability to pass the reference as inout and drill down into the properties of that property itself, which depends on the setter effectively being an "instantaneous" (synchronous, non-throwing) operation. Prohibiting async properties is a simpler rule than only allowing get-only async properties and subscripts.

Do I understand correctly that raised concerns do not apply to non-mutating setters, including setters in the class properties? They don't require self to be passed inout, so technically this restriction could be lifted in the future. I don't have any motivational examples, just curious.

Get-only async properties were later introduced by SE-0310: Effectful Read-only Properties.

2 Likes