What happened to `Task.sleep(for: Duration)`?

SE-0329 describes this API but it still hasn't landed in 5.7.

I remember some discussion around dropping the for:, but couldn't find anything about this particular API being dropped from the proposal. Is Task.sleep(until: .now + .seconds(3)) the preferred (verbose) way of achieving this, and if so should the proposal be updated? Or is this omission an oversight?

6 Likes

I couldn't find anything about it being dropped either. From SE-0329 (Third review):

  • It was observed that the preposition for: in sleep(for:) could be omitted as a needless word. However, there are good reasons to keep it: most importantly, that this is one method in an overload set where the alternatives ( sleep(until:) ) use a contrasting preposition. The Core Team agrees that for: should remain.

I opened a PR here: Add `Task.sleep(for: Duration)` by stephencelis · Pull Request #59203 · apple/swift · GitHub

9 Likes