[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this a kosher way to get/set values inside modules from C?

From: Rob Browning
Subject: Is this a kosher way to get/set values inside modules from C?
Date: 09 Jan 2001 22:49:14 -0600
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Is this "getter/setter pair" reasonable?  If not, then what's the
alternative?  I couldn't find docs for what gh_module_lookup expects,
and I couldn't find anything like gh_module_define...

(It would also be nice to have a way to check to see if a module
 exists before using it, but resolve_module never fails, and I didn't
 know what the alternative was.)


static void
gw_guile_module_define(SCM module_name_list, const char *sym, SCM value)
  SCM new_module = scm_resolve_module(module_name_list);
  SCM original_module = scm_select_module(new_module);
  gh_define(sym, value);

static SCM
gw_guile_module_lookup(SCM module_name_list, const char *sym)
  static SCM module_variable = SCM_BOOL_F;
  SCM module = scm_resolve_module(module_name_list);
  SCM variable;

  if(module_variable == SCM_BOOL_F)
    module_variable = gh_eval_str("module-variable");

  variable = gh_call2(module_variable, module, gh_symbol2scm(sym));
  if(variable == SCM_BOOL_F) return SCM_UNDEFINED;
  return scm_variable_ref(variable);

Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930

reply via email to

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