To help you get up and running, this chapter presents a couple of simple programs that demonstrate how to use Guile.
If the details of how the program works are not entirely clear, never fear. The chapters following will fill in the details about how Guile operates. In this chapter, the focus will be on an overview of the pragmatic details of putting it all together.
To write a Guile application, you need a C compiler, the Guile libraries and tools, the make application, and a coder-friendly editor.
I'll run through some quick tests on how to check if you have everything you need. These tests assume the GNU versions of these tools: the GNU compiler gcc, GNU make, and some common editors GNU/Linux editors.
For other environments, especially those that use IDE-based C compilers, like Microsoft Visual C++ or OpenWatcom C, some of this information will not apply. For those that use other environments, some hints are listed at the end of this section.
The Guile package consists of various libraries, a collection of scheme code, and some executable programs. If Guile has been installed normally on your system, the commands guile and guile-config should be present. To test for the presence of Guile and to check the version number of Guile that your are using, type this: guile --version. This should return the version number of the Guile distribution installed on your machine. If the file is not found, either Guile is not installed or is installed incorrectly. Check Appendix A for help on installing guile.
The examples in this book are known to work with Guile 1.6.4.
The program guile-config should also be present. guile-config is a utility used in compiling C programs that link to the Guile library. The command guile-config compile gives the necessary compile flags, and the command guile-config link gives the linker flags.
For those in the GNU and Linux world, GCC is the most common compiler. Since this book is based on Guile 1.6.4, you must have at least GCC version FIXME to ensure that your programs compile correctly. To test the existence and version of your compiler type this: gcc --version.
Since compiling Guile is simplified by using guile-config program to provide compile flags, it is important to have a make program that allows shell escapes, like this:
CFLAGS= `guile-config compile`
Guile is a superset of Scheme, which is a dialect of Lisp. Lisp, Scheme, and Guile are all about parentheses. Having an editor that counts parentheses is critical for coding in Guile.
Emacs has these very useful commands for Scheme programming.
forward-list: (ESC Ctrl-n or Alt-Ctrl-n) Move forward over a parenthetical group
backward-list: (Esc Ctrl-p or Alt-Ctrl-p) Move backward over a parenthetical group
backward-up-list: (Esc Ctrl-u or Alt-Ctrl-u) Move up in parenthesis structure
down-list: (Esc Ctrl-d) Move down in parenthesis structure
The EMACS tags program, etags, creates a table of function definitions, it works fine in a mixed C/Scheme environment. Just run etags *.c *.h Makefile *.scm to generate the TAGS table. Then you can use the command find-tag (ESC .) to jump to a specific definition.