4 @setfilename guile.info
5 @settitle Guile Reference Manual
10 @include lib-version.texi
11 @include effective-version.texi
14 This manual documents Guile version @value{VERSION}.
16 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free
19 Permission is granted to copy, distribute and/or modify this document
20 under the terms of the GNU Free Documentation License, Version 1.3 or
21 any later version published by the Free Software Foundation; with
22 no Invariant Sections, with the Front-Cover Texts being ``A GNU
23 Manual,'' and with the Back-Cover Text ``You are free to copy and
24 modify this GNU Manual.''. A copy of the license is included in the
25 section entitled ``GNU Free Documentation License''.
31 @c We no longer use the category "primitive" to distinguish C-defined
32 @c Scheme procedures from those defined in Scheme. Instead, the
33 @c reference manual now includes a C declaration as well as a Scheme
34 @c declaration for each procedure that is available in both Scheme and
37 @c When adding a new reference entry to the Guile manual, please
38 @c document it with @deffn using one of the following categories:
45 @c If the entry is for a new primitive, it should have both a @deffn
46 @c {Scheme Procedure} line and a @deffnx {C Function} line; see the
47 @c manual source for plenty of existing examples of this.
49 @c For {C Function} entries where the return type and all parameter
50 @c types are SCM, we omit the SCMs. This is easier to read and also
51 @c gets round the problem that Texinfo doesn't allow a @deftypefnx
54 @c For a list of Guile primitives that are not yet incorporated into the
55 @c reference manual, see the file `new-docstrings.texi', which holds all
56 @c the docstrings snarfed from the libguile C sources for primitives
57 @c that are not in the reference manual. If you have worked with some
58 @c of these concepts, implemented them, or just happen to know what they
59 @c do, please write up a little explanation -- it would be a big help.
60 @c Alternatively, if you know of any reason why some of these should
61 @c *not* go in the manual, please let the mailing list
62 @c <guile-devel@gnu.org> know.
64 @c Define indices that are used in the Guile Scheme part of the
65 @c reference manual to group stuff according to whether it is R5RS or a
69 @c vnew - For (some) new items, indicates the Guile version in which
70 @c item first appeared. In future, this could be made to expand to
71 @c something like a "New in Guile 45!" banner.
76 @c The following, @le{} and @ge{}, are standard tex directives, given
77 @c definitions for use in non-tex.
88 @c @cross{} is a \times symbol in tex, or an "x" in info. In tex it works
89 @c inside or outside $ $.
91 \gdef\cross{\ifmmode\times\else$\times$\fi}
99 @c @m{T,N} is $T$ in tex or @math{N} otherwise. This is an easy way to give
100 @c different forms for math in tex and info.
112 @c @nicode{S} is plain S in info, or @code{S} elsewhere. This can be used
113 @c when the quotes that @code{} gives in info aren't wanted, but the
114 @c fontification in tex or html is wanted. @alias is used rather
115 @c than @macro because backslashes don't work properly in an @macro.
128 @dircategory The Algorithmic Language Scheme
130 * Guile Reference: (guile). The Guile reference manual.
133 @setchapternewpage odd
137 @comment The title is printed in a large font.
138 @title Guile Reference Manual
139 @subtitle Edition @value{EDITION}, revision @value{MANUAL-REVISION}, for use with Guile @value{VERSION}
140 @c @subtitle $Id: guile.texi,v 1.49 2008-03-19 22:51:23 ossau Exp $
142 @c See preface.texi for the list of authors
143 @author The Guile Developers
145 @c The following two commands start the copyright page.
147 @vskip 0pt plus 1filll
148 @vskip 0pt plus 1filll
156 @c Where to find Guile examples.
157 @set example-dir doc/examples
160 @node Top, Preface, (dir), (dir)
161 @top The Guile Reference Manual
175 * Programming in Scheme::
185 * Guile Implementation::
191 * GNU Free Documentation License:: The license of this manual.
205 @include preface.texi
211 @include scheme-ideas.texi
212 @include scheme-reading.texi
214 @node Programming in Scheme
215 @chapter Programming in Scheme
217 Guile's core language is Scheme, and a lot can be achieved simply by using Guile
218 to write and run Scheme programs --- as opposed to having to dive into C code.
219 In this part of the manual, we explain how to use Guile in this mode, and
220 describe the tools that Guile provides to help you with script writing,
221 debugging and packaging your programs for distribution.
223 For detailed reference information on the variables, functions
224 etc. that make up Guile's application programming interface (API),
225 @xref{API Reference}.
228 * Guile Scheme:: Guile's implementation of Scheme.
229 * Guile Scripting:: How to write Guile scripts.
230 * Using Guile Interactively:: Guile's REPL features.
231 * Using Guile in Emacs:: Guile and Emacs.
234 @include scheme-intro.texi
235 @include scheme-scripts.texi
236 @include scheme-using.texi
238 @node Programming in C
239 @chapter Programming in C
241 This part of the manual explains the general concepts that you need to
242 understand when interfacing to Guile from C. You will learn about how
243 the latent typing of Scheme is embedded into the static typing of C, how
244 the garbage collection of Guile is made available to C code, and how
245 continuations influence the control flow in a C program.
247 This knowledge should make it straightforward to add new functions to
248 Guile that can be called from Scheme. Adding new data types is also
249 possible and is done by defining @dfn{smobs}.
251 The @ref{Programming Overview} section of this part contains general
252 musings and guidelines about programming with Guile. It explores
253 different ways to design a program around Guile, or how to embed Guile
254 into existing programs.
256 For a pedagogical yet detailed explanation of how the data representation of
257 Guile is implemented, @xref{Data Representation}. You don't need to know the
258 details given there to use Guile from C, but they are useful when you want to
259 modify Guile itself or when you are just curious about how it is all done.
261 For detailed reference information on the variables, functions
262 etc. that make up Guile's application programming interface (API),
263 @xref{API Reference}.
266 * Linking Programs With Guile:: More precisely, with the libguile library.
267 * Linking Guile with Libraries:: To extend Guile itself.
268 * General Libguile Concepts:: General concepts for using libguile.
269 * Defining New Types (Smobs):: Adding new types to Guile.
270 * Function Snarfing:: A way to define new functions.
271 * Programming Overview:: An overview of Guile programming.
274 @include libguile-linking.texi
275 @include libguile-extensions.texi
276 @include libguile-concepts.texi
277 @include libguile-smobs.texi
278 @include libguile-snarf.texi
279 @include libguile-program.texi
282 @chapter API Reference
284 Guile provides an application programming interface (@dfn{API}) to
285 developers in two core languages: Scheme and C. This part of the manual
286 contains reference documentation for all of the functionality that is
287 available through both Scheme and C interfaces.
290 * API Overview:: Overview of the Guile API.
291 * Deprecation:: Obsolete back-compatible APIs.
292 * The SCM Type:: The fundamental data type for C code.
293 * Initialization:: Initializing Guile.
294 * Snarfing Macros:: Macros for snarfing initialization actions.
295 * Simple Data Types:: Numbers, strings, booleans and so on.
296 * Compound Data Types:: Data types for holding other data.
297 * Smobs:: Defining new data types in C.
298 * Procedures:: Procedures.
299 * Macros:: Extending the syntax of Scheme.
300 * Utility Functions:: General utility functions.
301 * Binding Constructs:: Definitions and variable bindings.
302 * Control Mechanisms:: Controlling the flow of program execution.
303 * Input and Output:: Ports, reading and writing.
304 * LALR(1) Parsing:: Generating LALR(1) parsers.
305 * Read/Load/Eval/Compile:: Reading and evaluating Scheme code.
306 * Memory Management:: Memory management and garbage collection.
307 * Modules:: Designing reusable code libraries.
308 * Foreign Function Interface:: Interacting with C procedures and data.
309 * Scheduling:: Threads, mutexes, asyncs and dynamic roots.
310 * Options and Config:: Configuration, features and runtime options.
311 * Other Languages:: Emacs Lisp, ECMAScript, and more.
312 * Internationalization:: Support for gettext, etc.
313 * Debugging:: Debugging infrastructure and Scheme interface.
314 * Code Coverage:: Gathering code coverage data.
317 @include api-overview.texi
318 @include api-deprecated.texi
319 @include api-scm.texi
320 @include api-init.texi
321 @include api-snarf.texi
322 @include api-data.texi
323 @include api-compound.texi
324 @include api-smobs.texi
325 @include api-procedures.texi
326 @include api-macros.texi
327 @include api-utility.texi
328 @include api-binding.texi
329 @include api-control.texi
331 @include api-lalr.texi
332 @include api-evaluation.texi
333 @include api-memory.texi
334 @include api-modules.texi
335 @include api-foreign.texi
336 @include api-scheduling.texi
337 @c object orientation support here
338 @include api-options.texi
339 @include api-languages.texi
340 @include api-i18n.texi
341 @include api-debug.texi
342 @include api-coverage.texi
345 @chapter Guile Modules
348 * SLIB:: Using the SLIB Scheme library.
349 * POSIX:: POSIX system calls and networking.
350 * getopt-long:: Command line handling.
351 * SRFI Support:: Support for various SRFIs.
352 * R6RS Support:: Modules defined by the R6RS.
353 * Pattern Matching:: Generic pattern matching constructs.
354 * Readline Support:: Module for using the readline library.
355 * Pretty Printing:: Nicely formatting Scheme objects for output.
356 * Formatted Output:: The @code{format} procedure.
357 * File Tree Walk:: Traversing the file system.
358 * Queues:: First-in first-out queuing.
359 * Streams:: Sequences of values.
360 * Buffered Input:: Ports made from a reader function.
361 * Expect:: Controlling interactive programs with Guile.
362 * sxml-match:: Pattern matching of SXML.
363 * The Scheme shell (scsh):: Using scsh interfaces in Guile.
364 * Tracing:: Tracing program execution.
369 @include mod-getopt-long.texi
370 @include srfi-modules.texi
373 @include repl-modules.texi
374 @include misc-modules.texi
377 @c XXX: Would be nicer if it were close to the (sxml simple) documentation.
378 @include sxml-match.texi
381 @include scheme-debugging.texi
383 @node Standard Library
384 @chapter Standard Library
387 @include standard-library.texi
392 @node Guile Implementation
393 @chapter Guile Implementation
395 At some point, after one has been programming in Scheme for some time,
396 another level of Scheme comes into view: its implementation. Knowledge
397 of how Scheme can be implemented turns out to be necessary to become
398 an expert hacker. As Peter Norvig notes in his retrospective on
399 PAIP@footnote{PAIP is the common abbreviation for @cite{Paradigms of
400 Artificial Intelligence Programming}, an old but still useful text on
401 Lisp. Norvig's retrospective sums up the lessons of PAIP, and can be
402 found at @uref{http://norvig.com/Lisp-retro.html}.}, ``The expert Lisp
403 programmer eventually develops a good `efficiency model'.''
405 By this Norvig means that over time, the Lisp hacker eventually
406 develops an understanding of how much her code ``costs'' in terms of
409 This chapter describes Guile as an implementation of Scheme: its
410 history, how it represents and evaluates its data, and its compiler.
411 This knowledge can help you to make that step from being one who is
412 merely familiar with Scheme to being a real hacker.
415 * History:: A brief history of Guile.
416 * Data Representation:: How Guile represents Scheme data.
417 * A Virtual Machine for Guile:: How compiled procedures work.
418 * Compiling to the Virtual Machine:: Not as hard as you might think.
421 @include history.texi
422 @include data-rep.texi
424 @include compiler.texi
426 @include autoconf.texi
428 @node GNU Free Documentation License
429 @appendix GNU Free Documentation License
438 @include indices.texi
439 @include scheme-indices.texi