The #:keep 'results argument makes thread very similar to delay/thread (and, by extension, delay/sync or delay/idle). The big difference I see is that the promises catch exceptions and raise them when forces, whereas thread uses the exception handler, and a thread that ended in an exception will have (void) as its result, like a #:keep #f thread:
> (list (thread-wait (thread #:keep 'results (lambda () (+ "oops")))))
+: contract violation
expected: number?
given: "oops"
[,bt for context]
'(#<void>)
Maybe this makes sense: catching exceptions might be expensive, and maybe it's useful to have this as a lower-level mechanism. On the other hand, I'd guess catching exceptions is a relatively common desideratum, and maybe the implementation of thread is in a position to implement it especially efficiently, or just conveniently. Potentially a #:keep result/exn option could be added later.
It doesn't seem like there's a way to tell currently (without controlling the thread's thunk) if a thread terminated normally, with an exception, or by being killed.
Eventually, it would be nice to support parallelism for delay/thread and friends.
Finally, the existence of delay/idle led me to notice that the docs for system-idle-evt probably need an update for parallel threads:
Returns an event that is ready for synchronization when the system is otherwise idle: if the result event were replaced by
never-evt, no thread in the system would be available to run. In other words, all threads must be suspended or blocked on events with timeouts that have not yet expired.
From this experiment, it looks like parallel threads must also be blocked, but I'm not sure that behavior is desirable:
> (define stop? #f)
> (define n 0)
> (thread #:pool 'own (lambda ()
(let loop ()
(if stop?
(displayln n)
(begin (set! n (add1 n))
(loop))))))
#<thread>
> (list n (sync (system-idle-evt)) n (set! stop? #t) n)
^Cuser break [,bt for context]
On the other hand, syncing on (system-idle-evt) in a parallel thread seems to work fine:
> (sync (thread #:pool 'own
#:keep 'results
(lambda ()
(sync (system-idle-evt))
1)))
#<thread>