guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can scm_shell be interrupted?


From: Remco Bras
Subject: Re: Can scm_shell be interrupted?
Date: Fri, 16 May 2008 17:29:00 +0200

Hi Neil,

The REPL's input comes directly from stdin, usually attached to a
terminal. My app is a game engine whose games are written in guile.
Currently, the engine runs scm_shell in a separate thread on startup,
so the user can interactively program his games.

However, this causes issues if someone decides to distribute a game
written for this engine and doesn't want players to play around
interactively with the game data.

Perhaps the simplest solution is to only run the REPL on demand, since
the engine executes user-defined scheme files on startup anyway. If
this is done, perhaps the repl thread could execute a loop, checking a
POSIX condition variable or something similar and using scm_eval to
evaluate code read from stdin, only switching the REPL off between
reading expressions.

That approach does solve the problem where a user types half an
expression on a line, without finishing it on the next line. If a
user's REPL is suddenly turned off while he is still typing an
expression, that would be annoying, but probably the game code's fault
as I intend to offer this functionality as a part of the interface,
rather than controlling the REPL in the engine.

Regards,

Remco

On 5/12/08, Neil Jerram <address@hidden> wrote:
> Remco Bras <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]