GNU Info

Info Node: (guile-tut.info)More interesting programming with libguile

(guile-tut.info)More interesting programming with libguile


Next: Further examples Prev: How to get started with libguile Up: Guile in a Library
Enter node , (file) or (file)node

More interesting programming with libguile
==========================================

  The `learn0' program shows how you can invoke Scheme commands from a
C program.  This is not such a great achievement: the same could have
been done by opening a pipe to SCM or any other Scheme interpreter.

  A true extension language must allow "callbacks".  Callbacks allow
you to write C routines that can be invoked as Scheme procedures, thus
adding new primitive procedures to Scheme.  This also means that a
Scheme procedure can modify a C data structure.

  Guile allows you to define new Scheme procedures in C, and provides a
mechanism to go back and forth between C and Scheme data types.

  Here is a second program, `learn1', which demonstrates these
features.  It is split into three source files: `learn1.c',
`c_builtins.h' and `c_builtins.c'.  I am including the code here.

  Notice that `learn1' uses a Scheme master world, and the C routines
in `c_builtins.c' are simply adding new primitives to Scheme.

learn1.c
c_builtins.h
c_builtins.c
What learn1 is doing
Compiling and running learn1

automatically generated by info2www version 1.2.2.9