[plt-scheme] Repl during animation or simulation

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Wed Jun 3 22:48:39 EDT 2009

Greg Santucci wrote:
> On Thu, Jun 4, 2009 at 12:51 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:
> 
>> The alternative is to create a separate thread for your program's
>> execution. While it's running in the other thread, you can execute commands
>> in the REPL that change its behavior. PLT Scheme has many options for
>> managing concurrency and communication, from semaphores to channels
>> (synchronous and asynchronous) and synchronizable events.
>>
>>
> That's good to hear. How do you launch your app in a separate thread from
> the REPL? Is there an example of what you're describing?

It's easiest if you've already created a main function that starts all 
the work. Suppose it's called 'run-simulation'. Then instead of 
something like this

   (run-simulation some-arguments)

to start it in a new thread, write this instead:

   (thread (lambda () (run-simulation some-arguments)))

There are some distantly related examples of threads in "More: Systems 
Programming with PLT Scheme" in the help desk:

   http://docs.plt-scheme.org/more/

Ryan


Posted on the users mailing list.