guile-devel
[Top][All Lists]
Advanced

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

Re: What's the current-module during gh_eval_str?


From: Rob Browning
Subject: Re: What's the current-module during gh_eval_str?
Date: Wed, 26 Sep 2001 15:37:00 -0500
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7

Marius Vollmer <address@hidden> writes:

>> For example, what happens if you gh_eval_str from within a function
>> that's been published from within a module via dynamic-call and
>> gh_new_procedure?
>
> The module that contains the definition of a function has nothing to
> do with the module that is the current one when that functions calls
> `eval'.

So given

  void
  c_display_curmod(void) {
    gh_display(gh_eval_str("(current-module)"));
  }

and a scheme module that publishes this function

  (define-module (foo))
  (export c-display-curmod)

and then some other code like this:

  (use-modules (foo))
  (display (current-module)) (newline)
  (c-display-curmod) (newline)

Should I see the same module displayed twice because the module
referred to from within C code via eval_str, has nothing to do with
any module that C code might be accessed through?

If so, then I presume that if you want to write C functions that have
access to the bindings of the module they're being exported from, they
need to be using scm_module_lookup, or similar, right?

i.e. given

  (define-module (bar))
  (export get-internal-var)
  (define internal-var 7)

if get-internal-var is a binding for a C function published via
gh_new_procedure or similar, it couldn't just look up and return
internal-var's binding via gh_eval_str.  You'd have to say
scm_c_module_lookup(bar_module, "internal-var"), rather than
gh_eval_str("internal-var").

Did I get that right?  The reason I'm asking is that I'm having to
deal with various module issues in gnucash right now, and I want to
make sure I'm changing things in ways that will work long-term.

Thanks

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD



reply via email to

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