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 18:29:02 +0200
User-agent: KMail/1.9.9

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 via email to

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