unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Remco Bras <vrsoft@gmail.com>
To: guile-user@gnu.org
Subject: Re: Can scm_shell be interrupted?
Date: Fri, 16 May 2008 18:29:02 +0200	[thread overview]
Message-ID: <200805161829.02777.vrsoft@gmail.com> (raw)

Hello,

after the last exchange in this thread, I wrote and tested a prototype of a 
repl for my app. The code for this is as follows:

int
exec_guile_shell (void *unused_arg)
{
  scm_init_guile();
  /*Horribly inefficient*/
  while(1)
    {
      SCM_TICK;
      SDL_mutexP(repl_signal);
      
scm_simple_format(scm_current_output_port(),scm_from_locale_string(PROMPT),SCM_EOL);
      
scm_simple_format(scm_current_output_port(),scm_from_locale_string("~S"),scm_list_1
(scm_primitive_eval(scm_read(scm_current_input_port()))));
      scm_newline(scm_current_output_port());
      SDL_mutexV(repl_signal);
    }
  return 0;                     //never reached, just here to please gcc.
}

This is run when the app starts, after using scm_c_define_gsubr to define the 
primitive interface my app exports and after scm_c_primitive_load is used to 
read in user-defined scheme files. When this function runs, the repl_signal 
mutex is already locked, after which a user's file may use (run-repl) to tell 
the main loop to unlock the mutex. 

For the most part, this works fine, but if I use this REPL to evaluate a call 
to one of the functions I have defined using scm_c_define_gsubr, for example 
(stop-repl), the function is unbound in the environment the REPL uses. I've 
tried using scm_interaction_environment() as a second argument to scm_eval 
rather than using scm_primitive_eval, but that did not solve this problem. 

I'm using guile 1.8.4 on GNU/Linux, in case that's relevant. Also, when 
evaluating files using scm_c_primitive_load, the previously defined functions 
are bound, regardless of whether they were defined by scm_c_define_gsubr or 
another file.

Regards,

Remco.




             reply	other threads:[~2008-05-16 16:29 UTC|newest]

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

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=200805161829.02777.vrsoft@gmail.com \
    --to=vrsoft@gmail.com \
    --cc=guile-user@gnu.org \
    /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).