Jule channel receive on closed channel: panic or zero value needs confirmation
0 reputation · 11 Jun 2022, 09:14 UTC
I am writing a Jule program that uses lightweight co-routines and channels for a worker-pool pattern, and the shutdown path depends on what happens when a receiver reads from a channel after it has been closed. The Jule documentation describes Go-style CSP concurrency, but I cannot find a definitive statement of the closed-channel receive semantics for the current compiler release.
My design constraint: workers loop on channel receives and must exit cleanly when the producer closes the channel. In Go this is handled with the two-value receive form (v, ok := <-ch), where a closed channel yields the zero value and ok == false. I need to know whether Jule mirrors this exactly, panics instead, or requires a different idiom, because a panic-on-receive would force a different shutdown design.
Assume a recent Jule compiler from the official repository, transpiling through the host C++ toolchain.
- Does receiving from a closed channel in current Jule return the element type's zero value, panic, or is the behavior undefined?
- Does Jule support a two-value or boolean receive form to distinguish closure from a real zero-value element?
- Is sending on a closed channel a guaranteed panic, matching Go, or does it differ?