Copyright (C) 2000-2012 |
GNU Info (guile-tut.info)More interesting programming with libguileMore 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. automatically generated by info2www version 1.2.2.9 |