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]

(lambda (foo) (some-c-function)) - can that C function get foo ?


Hello guys,

This is a strange subject for this mail, but it's also some "strange"
problem.

I'm using some C code like this:

====
static SCM
test (void)
{
  return gh_eval_str ("foo");
}

void
scm_init_gdb_gdb_module ()
{
  gh_new_procedure ("testfunc", test, 0, 0, 0);
}
====

Then I try calling it in guile like this:

====
(let ((foo "bar")) (testfunc))
====

all I get is an "Unbound variable: foo" error. Same for the following:

====
(define bar (lambda (foo) (testfunc)))
(bar 10)
====

This works without problems when I define "foo" in the top-level env
like this:

====
guile> (define foo "bar")
guile> (testfunc)
"bar"
====

Is this a guile bug or am I doing something wrong ?

In general, when you call a C function inside a (let ...) or a (lambda ...)
expressions is it possible to access the variables that are defined locally
in the scope of that expression ?

-- 
Martin Baulig - martin@home-of-linux.org - http://www.home-of-linux.org

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