Run the following program in csi:
(use posix srfi-18)
(thread-start! (let ((max 5)
(i 0))
(letrec ((thunk (lambda ()
(when (< i max)
(print i)
(thread-sleep! 1)
(set! i (+ i 1)))
(thunk))))
thunk)))
I'm expecting it to print 0-5. But the result is the following:
,----
| #;2> #<thread: thread0>
| #;3> 0
|
| what?
| Error: unbound variable: what?
| #;3> 1
| 2
| 3
| 4
`----
It prints the first number 0, which is called before thread-sleep!.
After that, it'll wait for me to input something random(here, "what?"),
then it'll continute running the thread.
The other problem is that after running this thread, and even after it's
finished, csi starts to takes up to around 97% cpu usage!! on my dual
core macbook. Then I have to restart csi.