I think this is very necessary in order to make async
APIs feel at home in Swift. I'm a bit less sure this is necessary when it comes to throwing, but I can't really find a reason to object.
My only concern with the syntax is: how does it evolve in protocol declarations? Currently we allow this:
protocol P {
var p1: Int { get }
}
With this proposal we'll allow this:
protocol P {
var p1: Int { get async throws }
}
And maybe in the future we'll allow this:
protocol P {
var p2: Int { get async throws nonmutating set }
}
I feel it's a bit hard to tell where the get
declaration ends and when the set
declaration starts now that some attributes go after the get
, but I don't really see how to improve it without bringing other inconsistencies. And we still haven't added typed throw to the keyword soup either.
I'm not concerned enough by this to say the current proposal needs another syntax, but it remains on the back of my mind that we may eventually have to do something about it.