SE-0472: Starting tasks synchronously from caller context

Thought experiment:

Shouldn't this "run immediately" behavior be the default?

To me, it is not so dissimilar from the "nonisolated async func must always hop off an actor" OG idea that is now (thank goodness) amended with "inherit by default" in SE-0461.

So, what if,

Task {
   // this stays in-line by default
   // just like ".immedeately" or however it is spelled
   await actualSuspension()
   // now we are in "task-land"
}

is the default, and if you need to "defer" execution, there could be a

Task.defer { }
// or 
Task.schedule { }
// or
Task.async { }

or something similar? Feels like an easier time naming to me.

One could argue "ship has sailed" - but looking at the behavior change that was pulled off with SE-0461, nothing seems impossible ; )

So, the question is: Is the current Task { } behavior (of always off-loading/deferring) actually the correct default?

I would go as far as saying: maybe not? :thinking:

11 Likes