This is the mail archive of the guile@sources.redhat.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]

gh_module_lookup(vec, *sname); How do I get vec?



I am once again trying guile as an embedded language for some
calculations I am doing.  My needs are relatively simple, in general
the C world and the scheme world exist separately.  Although crude, I
pass data back and forth by having externs in C which I explicitly set
from scheme, e.g.

SCM set_k1a(SCM val)
{ 
  extern double k1a;
  k1a = gh_scm2double(val); return(SCM_UNSPECIFIED);
}

Of course some SCM routines return values as well.

My problem now is that I have a SCM routine which is called via
gh_lookup() with the intent that I can use alternate routines at the
scheme level.  I do the following, in a C (SCM) routine:

  func1 = gh_lookup("save-conc-maybe");
  func2 = gh_lookup("conc-check");    
  .
  .
  .
  tv = gh_call2(func1,gh_long2scm((long)nload),func2);

Before entering the repl (gh_repl()) I have the following:

  gh_new_procedure1_0("conc-check-default",conc_check_default);
  gh_new_procedure2_0("save-conc-maybe",save_conc_maybe);
  gh_eval_str("(define conc-check conc-check-default)");

This works as expected.

However, unless I'm wrong, all of this is in the (guile) module, while
I am in the (guile-user) module once I enter the repl.  If I change
the define for 'conc-check it has no effect on the subsequent
evaluation of the gh_lookup("conc-check") statement.

If I change to the root module
(set-current-module the-root-module) 
and then do the define it is visible.  However I can't find an easy
way to get back to the (guile-user) module, since any variable I save
the module in is not visible in (guile).  In any case this is very
inelegant.  

I'd like to be able to handle this like you do in Common Lisp or Perl
but I can't seem to find a way.  Either I need to get the gh_lookup()
to lookup in the (guile-user) module (but also get the default define
into (guile-user), which can probably be done in a .scm file loaded
later), or I need to get my define in (guile-user) into (guile).
gh_module_lookup() wants a vector, which appears to be the obarry
hash, but the variables for modules return records.

Having switched from scm to guile, I'm now finding these module
problems to be very frustrating, although I'm enjoying goops.  Of
course scm and goops (and stk and perl and python) all have good
documentation.  Could someone point me to the documentation for how to
use the module system and how to interact with it from the C level.
If there is no such documentation can I just turn off the module
system and get a single namespace and get some work done?

-john

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