[plt-scheme] (thread read)

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Thu Jun 7 12:56:08 EDT 2007

Thanks. But this doesn't solve the puzzle at all.

I put

(thread (lambda () (print (read))))
(sleep 100)

in the Definition window. The `sleep' should block the original thread 
trying to read.

Running the program, the first (print (read)) works fine. But then I 
will still infinitely many input boxes.

Chongkai

Jens Axel Søgaard wrote:
> Chongkai Zhu skrev:
>> What is
>>
>> (thread read)
>>
>> suppose to do? Trying on both DrScheme and MzScheme, version 370 
>> [3m], I got different effects (in DrScheme, even different from run 
>> to run).
>>
>> Doing more experiments in DrScheme only confuse me more. Could anyone 
>> help clarify? Thanks.
>
> The original thread (the REPL) and the new thread share the input port.
> When you type something at the REPL either the REPL *or* the new thread
> will read it. If the thread reads it, nothing happens. If the
> REPL reads it it gets evaluated as usual.
>
> If the REPL reads part of an expression and the threads read some
> then...
>
> Compare:
>
> (parameterize
>     ([current-input-port
>         (open-input-string "This is read by the thread")])
>   (thread (lambda ()
>     (display (read)))))
>



Posted on the users mailing list.