This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
(lambda (foo) (some-c-function)) - can that C function get foo ?
- To: guile@sourceware.cygnus.com
- Subject: (lambda (foo) (some-c-function)) - can that C function get foo ?
- From: Martin Baulig <martin@home-of-linux.org>
- Date: 30 Jun 1999 22:15:05 +0200
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