[plt-scheme] (thread read)

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jun 7 12:45:29 EDT 2007

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)))))

-- 
Jens Axel Søgaard



Posted on the users mailing list.