Download Guile Programmer`s Manual - Subdude-site
Transcript
Chapter 6: Libguile reference 19 6 Libguile reference The Guile interpreter is essentially Aubrey Jaer's SCM interpreter (see section \Overview" in SCM: a portable scheme interpreter) with some modications to make it suitable as an embedded interpreter. Part of the modication has been to provide a restricted interface to limit access to the SCM internals; this is called the gscm_ interface, or libguile interface. If you are programming with Guile, you should only use the C subroutines described in this manual, which all begin with gscm_. If instead you are extending Guile, you have the entire SCM source to play with. This manual will not help you at all, but you can consult Aubrey Jaer's SCM manual (see section \Internals" in SCM: a portable scheme interpreter). If you are adding a module to Guile, I recommend that you stick to the gscm_ interface: this interface is guaranteed to not change drastically, while the SCM internals might change as Guile is developed. 6.1 Libguile preliminaries To use libguile, you must have the following toward the beginning of your C source: #include <guile/gscm.h> When you link, you will have to add at least -lguile to the list of libraries. If you are using more of Guile than the basic scheme interpreter, you will have to add more libraries. If you use the Tk toolkit, add -lgtcltk -ltk4.1 -ltcl7.5 -lX11. If you use the posix library goonix, add -lgoonix. If you use the threads package, add -lthreads. If you use these extra packages, make sure you look at Section 6.3 [Starting and controlling the interpreter], page 20: it will show you what startup code you need to initialize each of these extra libraries. 6.2 Data types dened by libguile The following C constants and data types are dened in libguile: GSCM status Data type A data type returned by many gscm_ routines. Its value is meant to be interpreted by gscm_error_msg() if it is not GSCM_OK. GSCM top level Data type The data type used to store information about the scheme top levels. SCM Data type This is a C data type used to store all scheme data, no matter what the scheme type. Values are converted between C data types and the SCM type with utility functions described below (see Section 6.7 [Converting data between C and scheme], page 22). GSCM OK A constant returned by gscm_ calls when there was no error. Constant