(guile-tut.info.gz) More interesting programming with libguile
Info Catalog
(guile-tut.info.gz) How to get started with libguile
(guile-tut.info.gz) Guile in a Library
(guile-tut.info.gz) Further examples
4.4 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.
Menu
* learn1.c
* c_builtins.h
* c_builtins.c
* What learn1 is doing
* Compiling and running learn1
Info Catalog
(guile-tut.info.gz) How to get started with libguile
(guile-tut.info.gz) Guile in a Library
(guile-tut.info.gz) Further examples
automatically generated byinfo2html