Quite sound for nursery being a primitive building block for lexical scoping of concurrency structure.
I just realize I might be pursuing dynamic scoping regarding concurrency (besides contextual callbacks or effects). Gut feeling tells me that cancel-by-default might suite dynamic scoping of concurrency better.
GHC implements light weighted thread in Haskell, much akin to goroutine in Go in the M:N scheduling regard. I baked a parasitic interpreted language Edh as an object layer on GHC’s runtime, mapping Edh thread 1:1 to GHC thread.
A GHC process, or more precisely, GHC RTS (runtime system) silently stops all other threads when the main thread finishes, I currently follows this model, while multiple Edh programs can be started from a single GHC process, the main Edh thread of a program (its descendant threads as well) can use
go statement to spawn more threads, and a forkee thread inherit call stack from its forker, so the forker’s exception handler can run in forkee threads upon exception, then any exception if uncaught by handlers, will be
throwTo (using GHC’s asynchronous exception mechanism) the main thread, effectively causing program termination, thus all threads belonging to that program terminated.
Inspired by nursery and Trio, I think I need a primitive to delimit the scope of an Edh program, currently I only have Haskell api
runEdhProgram , no construct for Edh code to do it. I hesitate to give it a good name and syntax, do you have suggestions?