[plt-scheme] mred in console mode on Debian

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Apr 14 14:30:11 EDT 2008

That leaves you in the unfortunate state where callbacks in your GUI
will be evaluated concurrently with code submitted at the REPL. For
example, if you evaluate this code:

(define (p x)
  (let loop ()
    (display x)
    (sleep 1/10)
    (loop)))

(define f (new frame% [label ""]))
(define b (new button%
               [label "button"]
               [parent f]
               [callback (λ (x y) (p ":"))]))
(send f show #t)

and then call

  > (p ".")

in the repl you'll periods appearing. Then, if you click the button,
you'll see colons and periods interspersed.

Probably you don't want those running concurrently.

Instead, you'd need to change the REPL so that it uses queue-callback
to evaluate the expressions as if they were callbacks.

Matthew has changed mred so that it works like this by default in the
v4 pre-release builds. Maybe the easiest thing is just to start using
them?

Robby

On Mon, Apr 14, 2008 at 1:08 PM, dragal V2.0.3 <dragal23 at gmail.com> wrote:
> After a fairly large amount of head scratching (I am new to threaded
>  programming) and some further reading of the mred documentation i
>  decided to try evaluating
>
>  (current-eventspace (make-eventspace))
>
>  before doing anything.
>
>  This does seem to do the trick.
>
>  Robby findlers reply to my original message said that the initially
>  created event space ran in the same thread as the repl, whereas the
>  new eventspace creates its own new handler thread.
>  It seems to me the most obvious way to start mred would have been to
>  initialise the repl and then spawn a new eventspace with its own
>  separate thread.
>
>  Is there a reason why my aproach is not more generally used? Are there
>  any problems with simply replacing the initial event space.
>
>
>  Thanks,
>
>  Dragal
>

Posted on the users mailing list.