This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Can the Guile library be reentrant


On Sat, Jul 25, 1998 at 02:56:49PM -0700, Steven Rubin wrote:
> I'm new to this list, but I scanned the archives and didn't find what I
> wanted to know, so here goes...
> 
> I am porting Guile into a large CAD system called Electric (which will soon
> be a GNU offering).  The problem I am having is that Guile wants control (I
> call "gh_enter" and it never returns).  This is unacceptable for the
> structure of my program, which is message-based, and expects to return to
> the operating system for interrupt-based control.

This is exactly the problem that I had. This is one of the reasons why
it is difficult to `retrofit' guile into an application -- because guile
like to do EVERYTHING (including all the interrupt handling, error handling
and so on). I suggest that you try an alternative method which is to isolate
your major data entities and turn them into smobs. This has the nice feature
that the guile garbage collector will now help you (oh but you had your own
memory management code and its fast, debugged and implemented -- keep it but
only use it internal to the smob, that way guile will call your code when
it sweeps the smob). Guile will play with your data as high level entities.
This is my methodology (for the moment) but I haven't got GUI messages
running through the works yet so my approach may come unstuck on me.

> Is there an alternate to "gh_enter" which does some initialization and then
> returns, so that the C program can then re-enter when it needs to do
> evaluations?

gh_eval_str (char *scheme_code)
gh_eval_str_with_catch (char *scheme_code, scm_catch_handler_t handler)
gh_eval_str_with_standard_handler (char *scheme_code)
gh_eval_str_with_stack_saving_handler (char *scheme_code)

I think (guess) that these might help... maybe.

	- Tel