guile-devel
[Top][All Lists]
Advanced

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

Re: Creating modules from C


From: Alex Shinn
Subject: Re: Creating modules from C
Date: 14 May 2001 11:12:52 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.100

>>>>> "Marius" == Marius Vollmer <address@hidden> writes:

    Marius> Ok.  It's "Drastic Measures Time".  [Thinking as I
    Marius> type...] People should be able to handle modules from C,
    Marius> in a way mostly similar to how they do it from Scheme.

    [...]

    Marius> The higher level interface to the module system consists
    Marius> of

    Marius>   - define-module MOD-NAME

    Marius>   - use-modules MOD-NAME...

    Marius>   - export NAME...

    Marius>   - the concept of the `current module'

So how would one define an exported function from C?  Something like

SCM module = scm_c_define_module("my-module", my_module_init);
SCM s_foo = scm_make_gsubr("foo", 0, 0, 0, foo);
scm_c_module_define(module, "foo", s_foo);
scm_c_export("foo", NULL);

Is this right?  This requires either three steps for each function or
two steps plus keeping a list of the functions and exporting them
once.

IMHO, for things like SWIG and modules that define a large number of
exported functions (e.g. I'm working on SDL bindings), the cleanest
interface would be to have something like define-public available from
C.  Maybe

scm_c_define_public(module, "foo", 0, 0, 0, foo);

That way you have one place where your function is made available, and
you don't have to keep function lists synced up in your .c/.scm files.

-- 
Alex Shinn <address@hidden>
Lisper, Smalltalker, and all around poor speaker



reply via email to

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