At Wed, 20 Jul 2005 09:39:32 +0200,
felix winkelmann wrote:
> Absolutely. You can try out Thomas' suggestions. Alternatively, this is the 
> code
> from srfi-18.scm, that makes the repl non-blocking:
> 
>   (set! ##sys#read-prompt-hook
>     (let ([old ##sys#read-prompt-hook]
>         [thread-yield! thread-yield!] )
>       (lambda ()
>       (when (or (##sys#fudge 12) (##sys#tty-port? ##sys#standard-input))
>         (old)
>         (##sys#thread-block-for-i/o! ##sys#current-thread 0 #t)
>         (thread-yield!)))) ) )
> 
> Here is an adaption that might work:
> 
> (use srfi-18) 
> 
> (thread-start!
>  (lambda ()
>    (let loop ((i 1))
>      (thread-sleep! 1)
>      (print "[" i "]")
>      (loop (add1 i)))))
> 
> (define (my-repl)
>   (let loop ()
>     (print* "my-server> ")
>     (##sys#thread-block-for-i/o! (current-thread) 0 #t)
>     (thread-yield!)
>     (pp `(READ: ,(read)))
>     (loop) ) )
> 
> (my-repl)

Just adding two lines
    (##sys#thread-block-for-i/o! (current-thread) 0 #t)
    (thread-yield!)
really works fine in the interpreter. thanks!

Also, I was trying to make an egg for nonblocking stdin,
by copying lines from tcp.scm.
However lack of the experience of making eggs makes me hard to debug it.
Overall, I'm still not sure how to debug scheme code.
Attatched file is non-woking code, just in case somebody can have a look.

Daishi

Attachment: nbstdin.scm
Description: Binary data

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to