The fourth review of SE-0304: Structured Concurrency has ended and the proposal has been accepted with modifications.
Much of the fourth revision was about naming and the community was broadly positive about these changes, with discussion focused on a few specific points.
The naming of the function suspend
, that frees the task mid-function, was discussed. The core team agrees that the originally-proposed yield
is a better name. The risk of confusion with the potential future use of yield
in modify accessors is low, and the word yield
better describes what the function does.
It was noted in review that UnsafeTask
was missing a cancel
method. This will be added on acceptance.
The ability to omit self on task closures was discussed. Currently this is achieved through an implementation detail using underscored attributes. A similar approach appears for marker protocols in SE-0302: Sendable
and @Sendable
closures. In both cases, the core team is interested in exploring ways in which these capabilities could be generalized into public language features in the future, without feeling this needs to be done prior to accepting this proposal.
Regarding Task.detached { }
versus Task(.detached) { }
, the core team feels that while they both achieve the same goal of the effect of a label with no argument, Task.detached { }
is preferable as it does not require the addition of an extra enum type purely to indicate the task should be run detached.
Finally, the naming of Task
, and of the addTask
method on TaskGroup
, was extensively discussed. This was a tough decision for the core team to make, with differing opinions within the team. Creating a Task
and launching it are intentionally linked: tasks cannot be first created and then later launched. This combination of value creation and side effect does not have much precedent within the standard library on which to base the decision, and the existing naming practices offer guidance in different directions. The practice of using an initializer to create instances (here, of the Task
type), and the goal of omitting needless words, conflict with the guidance to use an active a verb that reflects the fact that creating a task also starts running that task. Prioritizing these conflicting guidelines is a matter of taste and judgement, and that naturally includes a level of subjectivity. Ultimately, the core team decided to accept the naming as proposed.
Thank you to everyone who participated in the review!