unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Remco Bras" <vrsoft@gmail.com>
To: "Neil Jerram" <neil@ossau.uklinux.net>
Cc: guile-user@gnu.org
Subject: Re: Can scm_shell be interrupted?
Date: Fri, 16 May 2008 17:29:00 +0200	[thread overview]
Message-ID: <20028b570805160829s6d7e83a8rc634f4dc0338c3c4@mail.gmail.com> (raw)
In-Reply-To: <87prrruuba.fsf@ossau.uklinux.net>

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 <neil@ossau.uklinux.net> wrote:
> Remco Bras <vrsoft@gmail.com> 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	other threads:[~2008-05-16 15:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-10 20:54 Can scm_shell be interrupted? Remco Bras
2008-05-12 20:43 ` Neil Jerram
2008-05-16 15:29   ` Remco Bras [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-05-16 16:29 Remco Bras
2008-06-01 21:58 ` Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20028b570805160829s6d7e83a8rc634f4dc0338c3c4@mail.gmail.com \
    --to=vrsoft@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=neil@ossau.uklinux.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).