guile-user
[Top][All Lists]
Advanced

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

how to access subr from scm module?


From: Viktor Pavlenko
Subject: how to access subr from scm module?
Date: Sun, 17 Nov 2002 16:19:28 -0500

Hi all,

I have the following situation:

1) a SCM procedure (*my-c-proc*) is defined in C and exported with
   scm_c_define_gsubr;
2) my program loads a SCM module (my-module.scm) by calling
   scm_c_use_module("my-module")
3) this module defines some SCM procedures I want to call from C code
4) these procedures will use *my-c-proc* mentioned in (1)

The problem is that *my-c-proc* is not visible in my-module and
scm_call_N will fail with

    ERROR: Unbound variable: *my-c-proc*

This procedure, however, is accessible from C since
scm_c_eval_string("*my-c-proc*") produces
#<primitive-procedure *my-c-proc*>.

I would prefer making a SCM module of my C procedures but they are
defined in the same code that wants to use them, so

    (define-module (my-c-procedures))
    (load-extension "??" "??")

doesn't seem useful. It would be OK though to load them as global
definitions, and scm_c_define_gsubr is supposed to do so according to
the docs:

     "Create a new subr object named NAME, based on the C function
     FUNCTION, make it visible to Scheme the value of as a global
     variable named NAME"

but that doesn't work for me. So what's the trick to make it work and
make it nice?

Thank you in advance.

Viktor




reply via email to

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