This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: probably faqs


Matthew Crosby <crosby@nago.cs.colorado.edu> writes:

> Hi!  I just recently started playing with Guile, and I have a couple
> of questions.  Probably mostly FAQs, but I didn't see anything in
> any of the docs I saw: This is all with 1.2, btw.

Soon 1.3 will be out, when it is I suggest you grab it.

> 1) I notice guile has native threading (cool).  I take it that it is
> thread safe, ie I can use a process with multiple pthreads and have
> some of them use guile?  Anything I should know about?

Guile uses it's own thread library, libqthreads.a.  This thread
library is not the same as pthreads, and does not work with it.  Yes,
getting pthread support for Guile is on the TODO list.  The only
way I know of to get guile working within a program that uses pthreads
is to confine your usage of guile to a single thread.  Using a work
queue, this can be feasible depending upon your requirements.

> 2)  Does anyone have any information about C++ interfacing to guile?
>     The fsf web page mentions that "Bill Nell has written a guile/C++ 
>     interface system", but the link from the page doesn't work.  
>     In particular, when I tried a simple app just using the c bindings,
>     I notice that there seems to be some "#ifdef __cplusplus extern C {"
>     missing in the header files, so the compiler is assuming c++ linkage.

I use guile with C++ all the time.  This is how I include the guile
header files:

#if defined(__cplusplus)
extern "C" {
#endif    

#include <libguile.h>
#include <guile/gh.h>

#if defined(__cplusplus)
}
#endif    

> Undefined                       first referenced
> symbol                             in file
> scm_boot_guile__FiPPcPFPviPPc_vPv   /var/tmp/cca003Ty1.o
> gh_new_procedure4_0__FPcPFv_l       /var/tmp/cca003Ty1.o
> gh_eval_file__FPc                   /var/tmp/cca003Ty1.o

This will be fixed if you include the guile headers as above.

>     I suppose I could just build a wrapper file, compile with C and
>     then call that, but that seems a little messy.  (Or, yes, I can
>     just put my own "extern C" in the header files.)
>     Should I check out SWIG?

Personally, I don't use SWIG, so I can't help much there.

> 3) I've been thinking about using guile as a network interface, ie
> binding to a port and then passing the socket to guile, so that you
> can just telnet in and get the guile interpreter.  Is this feasable?
> Has anyone done this?

Yes this is feasible, although maybe a bad idea from a security point
of view.  Check the mailing list archives for similar projects; I seem
to remember stuff like this under discussion.

-russ


-- 
Russell D. McManus / phone: 212-357-4901 / beep: 917-556-0708
Goldman, Sachs & Co. International Equities Technology

Linux: For IQs Higher Than 95