Remco Bras <[EMAIL PROTECTED]> writes:

> Hello,
>
> I have a question about guile. I'd like to know if it is feasible to run a 
> guile REPL and control when it runs. For example, consider the following 
> scenario. A package may or may not have a thread running scm_shell, when the 
> user requests that the package runs an REPL. The package responds by running 
> scm_shell in a thread and keeping that thread's ID. If the user wants the 
> package to stop the REPL at any moment, is there a way to do this safely? 

Where does the REPL's input come from?

If its stdin, being read in a blocking way (as is the default), it
would be tricky if the REPL thread did the read directly.  But you
could have a special stdin-reader thread, responsible for reading and
buffering lines of input, and then supplying them to whichever REPL
runs next.

What happens if the user wants to stop a package's REPL when the user
has already typed half a line of input into that REPL?

It might also be possible to make stdin non-blocking, and use select
to avoid trying to read before there is a whole line available.

If its a GUI app, it becomes less a matter of a REPL reading from a
port, and more a matter of a widget collecting input which can then be
passed into the REPL.  (Although the two approaches can be reconciled;
see graphical-repl.scm in guile-gnome.)  I think that fits slightly
more naturally with your idea of a selectable REPL, so may be easier
to implement in your app.

In summary: lots of options, need more detail about how your overall
app works and what you want it to look like.

Regards,
     Neil



Reply via email to