[Top][All Lists]

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

Re: Guile questions

From: Stephen Compall
Subject: Re: Guile questions
Date: 26 Aug 2004 16:39:24 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"Jim Norris" <address@hidden> writes:

> Does Guile let you dynamically link to dlls / object library files
> at run time without the need for header (*.h) files, *.def files, or
> *.lib files?  (or the Unix equivalent)

You can do this even in C, even fairly portably with libltdl.

> If it does, does Guile automatically load the function names into Guile's
> namespace at runtime?

Do you mean does it find all the so's exported symbols and generate
foreign-function interface calls, exporting the results to Scheme?

The usual manner of making a C library available to Guile is to
manually write a wrapper function, though the tools g-wrap and SWIG,
which use interface descriptions, are available to generate these
wrappers.  Here is an example:

#include <libguile.h>

SCM_DEFINE (jim_norris_puts, "jim-norris-puts", 1, 0, 0,
            (SCM string),
            "Put @var{string} on FILE* stdout.")
#define FUNC_NAME s_jim_norris_puts
  /* warning -- SCM_STRING_CHARS is deprecated.  Plus, one day the
     chars won't be null-terminated */
  fputs (SCM_STRING_CHARS (string), stdout);
  /* I don't think you have to do this (IIRC Guile waits for all
     threads to enter the SCM API before GC), but you might someday: */
  scm_remember_upto_here_1 (string);
#undef FUNC_NAME

init_jim_norris (void)
#include "jim_norris.x"

Then call guile-snarf -o jim_norris.x jim_norris.c, compile to a so,
add a module that calls
(load-extension "libjimnorris" "init_jim_norris")

If it's more complicated, you might create a Scheme module that
exports your bindings, then the magic renamery can be done.

> If the funtion names autoload, does Guile have a mechanism for
> allowing the user to select which dll's functions are in the name
> space at any given time? This is in case two dll's have functions
> with the same names and to speed up script interpretation.

You can control the symbol import how you like, including renaming
symbols, and even not importing symbols at all and using @ instead (@
is in HEAD, not 1.6.x).

> Are there any features users are asking for that Guile currently
> doesn't have? If so is there a need for someone to work on those?

If you have a piece of software, consider whether it could benefit
from having a powerful extension language built-in, like Guile, and
integrate it.

Stephen Compall or s11 or sirian

Sigh.  I like to think it's just the Linux people who want to be on
the "leading edge" so bad they walk right off the precipice.
(Craig E. Groeschel)

jihad argus STARLAN electronic surveillance spies

reply via email to

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