[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Invoking guile procs from C in an efficient way
From: |
Rob Browning |
Subject: |
Re: Invoking guile procs from C in an efficient way |
Date: |
Mon, 25 Oct 2004 11:51:06 -0500 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Andreas Rottmann <address@hidden> writes:
>> SCM proc = scm_c_lookup("my_proc");
>> scm_apply(proc, argslist, SCM_EOL);
>>
> I think it's:
>
> scm_apply(SCM_VARIABLE_REF(scm_c_lookup("my-proc")), argslist, SCM_EOL);
In some cases you can also cache the binding if you want to avoid
repeated lookups (using 1.6 interfaces):
foo()
{
static SCM my_proc = SCM_BOOL_F;
if(SCM_FALSEP(my_proc))
{
my_proc = scm_c_lookup("my-proc"); /* or scm_c_module_lookup */
/* check for failure here */
scm_permanent_object(my_proc); /* presumes you always need my_proc */
}
scm_apply(scm_variable_ref(my_proc), argslist, SCM_EOL);
}
Caveats apply -- i.e. don't call this before guile is initialized,
consider synchronization issues (if we ever let multiple posix threads
call guile at the same time), etc.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4