I'm also in favor of single verbs, and specifically: spawn
(always child task), detach
always NOT-child task, because it is simpler to reason and teach about:
- A: okey how do I make some tasks?
- B: you use
spawn
(coversgroup.spawn
, the upcomingspawn let
) - A: okey I know about spawn; what is
detach
? - B: Oh yeah don't detach, that's terrible, unless [...]
Whereas if both were "spawn" and "spawn but with some caveats, try not to use it". it becomes conflated in discussions and I can see this happening:
- A: so I spawned a task but it didn't get cancelled, why?
- B: how do you spawn?
- A:
spawnDetached
, only thing the compiler would let me use. - B: Oh yeah never spawn detached, [explanation follows ...]
So IMHO by using a completely different verb we make it clear that it's not "some spawn that the compiler will accept here" but a different thing I need to separately learn about, even if I then in my head learn "okey, so like spawn but not a child-task".
--
I also still think there might be the need for one other verb, similar to send
or something... where we want to not really detach but we're in a synchronous function and must call an async function; so we make a new task, but it inherits both execution context, priority, task-locals and everything else it can. With those three I think we'd have covered all use cases... The send
I don't know if everyone agrees with, but pretty sure we'll need something for "sync calling async" that is better than detach.