News for hackers. Stuff that matters.
Re:Structured Concurrency Definition by mananaysiempre on Sunday February 05, 2023 @01:02PM (#34667100)
Small quibble with the article:

It refers to Trio nurseries as “scopes”. I thought about them like that for a while, but don’t think that’s not exactly the right view now. As a subroutine, you can’t (usually) reach up into your parent static or dynamic scopes and cause new objects to be created there and outlive your own dynamic extent. (Tcl exempted.)

Because nurseries are first-class objects, though, you’re free to create a root nursery at startup and stick it in a global variable, after which everyone is free to create as many Go-style unaccountable threads as they want to. It’s just that you don’t have to. Yet passing worker threads their originating nursery so that they can spawn more peer workers is a moderately useful pattern.

TL;DR: Firsr-class nurseries are not quite scopes because they don’t enforce strict lifetime nesting between a spawned thread and the thread that caused it to be spawned.

Re:Structured Concurrency Definition by gavinhoward on Sunday February 05, 2023 @01:16PM (#34667234)
One of the tweaks I would use is to use the word "lifetimes" instead of scopes. I think this would since the problem you see because each object, even a nursery, has a lifetime, and threads are tied to those lifetimes.