4 @setfilename guile.info
5 @settitle Guile Reference Manual
10 @include effective-version.texi
13 This manual documents Guile version @value{VERSION}.
15 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free
18 Permission is granted to copy, distribute and/or modify this document
19 under the terms of the GNU Free Documentation License, Version 1.3 or
20 any later version published by the Free Software Foundation; with
21 no Invariant Sections, with the Front-Cover Texts being ``A GNU
22 Manual,'' and with the Back-Cover Text ``You are free to copy and
23 modify this GNU Manual.''. A copy of the license is included in the
24 section entitled ``GNU Free Documentation License''.
30 @c We no longer use the category "primitive" to distinguish C-defined
31 @c Scheme procedures from those defined in Scheme. Instead, the
32 @c reference manual now includes a C declaration as well as a Scheme
33 @c declaration for each procedure that is available in both Scheme and
36 @c When adding a new reference entry to the Guile manual, please
37 @c document it with @deffn using one of the following categories:
44 @c If the entry is for a new primitive, it should have both a @deffn
45 @c {Scheme Procedure} line and a @deffnx {C Function} line; see the
46 @c manual source for plenty of existing examples of this.
48 @c For {C Function} entries where the return type and all parameter
49 @c types are SCM, we omit the SCMs. This is easier to read and also
50 @c gets round the problem that Texinfo doesn't allow a @deftypefnx
53 @c For a list of Guile primitives that are not yet incorporated into the
54 @c reference manual, see the file `new-docstrings.texi', which holds all
55 @c the docstrings snarfed from the libguile C sources for primitives
56 @c that are not in the reference manual. If you have worked with some
57 @c of these concepts, implemented them, or just happen to know what they
58 @c do, please write up a little explanation -- it would be a big help.
59 @c Alternatively, if you know of any reason why some of these should
60 @c *not* go in the manual, please let the mailing list
61 @c <guile-devel@gnu.org> know.
63 @c Define indices that are used in the Guile Scheme part of the
64 @c reference manual to group stuff according to whether it is R5RS or a
68 @c vnew - For (some) new items, indicates the Guile version in which
69 @c item first appeared. In future, this could be made to expand to
70 @c something like a "New in Guile 45!" banner.
75 @c The following, @le{} and @ge{}, are standard tex directives, given
76 @c definitions for use in non-tex.
87 @c @cross{} is a \times symbol in tex, or an "x" in info. In tex it works
88 @c inside or outside $ $.
90 \gdef\cross{\ifmmode\times\else$\times$\fi}
98 @c @m{T,N} is $T$ in tex or @math{N} otherwise. This is an easy way to give
99 @c different forms for math in tex and info.
111 @c @nicode{S} is plain S in info, or @code{S} elsewhere. This can be used
112 @c when the quotes that @code{} gives in info aren't wanted, but the
113 @c fontification in tex or html is wanted. @alias is used rather
114 @c than @macro because backslashes don't work properly in an @macro.
127 @dircategory The Algorithmic Language Scheme
129 * Guile Reference: (guile). The Guile reference manual.
132 @setchapternewpage odd
136 @comment The title is printed in a large font.
137 @title Guile Reference Manual
138 @subtitle Edition @value{EDITION}, revision @value{MANUAL-REVISION}, for use with Guile @value{VERSION}
139 @c @subtitle $Id: guile.texi,v 1.49 2008-03-19 22:51:23 ossau Exp $
141 @c See preface.texi for the list of authors
142 @author The Guile Developers
144 @c The following two commands start the copyright page.
146 @vskip 0pt plus 1filll
147 @vskip 0pt plus 1filll
155 @c Where to find Guile examples.
156 @set example-dir doc/examples
159 @node Top, Preface, (dir), (dir)
160 @top The Guile Reference Manual
174 * Programming in Scheme::
184 * Guile Implementation::
190 * GNU Free Documentation License:: The license of this manual.
204 @include preface.texi
210 @include scheme-ideas.texi
211 @include scheme-reading.texi
213 @node Programming in Scheme
214 @chapter Programming in Scheme
216 Guile's core language is Scheme, and a lot can be achieved simply by using Guile
217 to write and run Scheme programs --- as opposed to having to dive into C code.
218 In this part of the manual, we explain how to use Guile in this mode, and
219 describe the tools that Guile provides to help you with script writing,
220 debugging and packaging your programs for distribution.
222 For detailed reference information on the variables, functions
223 etc. that make up Guile's application programming interface (API),
224 @xref{API Reference}.
227 * Guile Scheme:: Guile's implementation of Scheme.
228 * Guile Scripting:: How to write Guile scripts.
229 * Using Guile Interactively:: Guile's REPL features.
230 * Using Guile in Emacs:: Guile and Emacs.
233 @include scheme-intro.texi
234 @include scheme-scripts.texi
235 @include scheme-using.texi
237 @node Programming in C
238 @chapter Programming in C
240 This part of the manual explains the general concepts that you need to
241 understand when interfacing to Guile from C. You will learn about how
242 the latent typing of Scheme is embedded into the static typing of C, how
243 the garbage collection of Guile is made available to C code, and how
244 continuations influence the control flow in a C program.
246 This knowledge should make it straightforward to add new functions to
247 Guile that can be called from Scheme. Adding new data types is also
248 possible and is done by defining @dfn{smobs}.
250 The @ref{Programming Overview} section of this part contains general
251 musings and guidelines about programming with Guile. It explores
252 different ways to design a program around Guile, or how to embed Guile
253 into existing programs.
255 For a pedagogical yet detailed explanation of how the data representation of
256 Guile is implemented, @xref{Data Representation}. You don't need to know the
257 details given there to use Guile from C, but they are useful when you want to
258 modify Guile itself or when you are just curious about how it is all done.
260 For detailed reference information on the variables, functions
261 etc. that make up Guile's application programming interface (API),
262 @xref{API Reference}.
265 * Linking Programs With Guile:: More precisely, with the libguile library.
266 * Linking Guile with Libraries:: To extend Guile itself.
267 * General Libguile Concepts:: General concepts for using libguile.
268 * Defining New Types (Smobs):: Adding new types to Guile.
269 * Function Snarfing:: A way to define new functions.
270 * Programming Overview:: An overview of Guile programming.
273 @include libguile-linking.texi
274 @include libguile-extensions.texi
275 @include libguile-concepts.texi
276 @include libguile-smobs.texi
277 @include libguile-snarf.texi
278 @include libguile-program.texi
281 @chapter API Reference
283 Guile provides an application programming interface (@dfn{API}) to
284 developers in two core languages: Scheme and C. This part of the manual
285 contains reference documentation for all of the functionality that is
286 available through both Scheme and C interfaces.
289 * API Overview:: Overview of the Guile API.
290 * Deprecation:: Obsolete back-compatible APIs.
291 * The SCM Type:: The fundamental data type for C code.
292 * Initialization:: Initializing Guile.
293 * Snarfing Macros:: Macros for snarfing initialization actions.
294 * Simple Data Types:: Numbers, strings, booleans and so on.
295 * Compound Data Types:: Data types for holding other data.
296 * Smobs:: Defining new data types in C.
297 * Procedures:: Procedures.
298 * Macros:: Extending the syntax of Scheme.
299 * Utility Functions:: General utility functions.
300 * Binding Constructs:: Definitions and variable bindings.
301 * Control Mechanisms:: Controlling the flow of program execution.
302 * Input and Output:: Ports, reading and writing.
303 * Regular Expressions:: Pattern matching and substitution.
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-regex.texi
332 @include api-lalr.texi
333 @include api-evaluation.texi
334 @include api-memory.texi
335 @include api-modules.texi
336 @include api-foreign.texi
337 @include api-scheduling.texi
338 @c object orientation support here
339 @include api-options.texi
340 @include api-languages.texi
341 @include api-i18n.texi
342 @include api-debug.texi
343 @include api-coverage.texi
346 @chapter Guile Modules
349 * SLIB:: Using the SLIB Scheme library.
350 * POSIX:: POSIX system calls and networking.
351 * Web:: HTTP, the web, and all that.
352 * getopt-long:: Command line handling.
353 * SRFI Support:: Support for various SRFIs.
354 * R6RS Support:: Modules defined by the R6RS.
355 * Pattern Matching:: Generic pattern matching constructs.
356 * Readline Support:: Module for using the readline library.
357 * Pretty Printing:: Nicely formatting Scheme objects for output.
358 * Formatted Output:: The @code{format} procedure.
359 * File Tree Walk:: Traversing the file system.
360 * Queues:: First-in first-out queuing.
361 * Streams:: Sequences of values.
362 * Buffered Input:: Ports made from a reader function.
363 * Expect:: Controlling interactive programs with Guile.
364 * sxml-match:: Pattern matching of SXML.
365 * The Scheme shell (scsh):: Using scsh interfaces in Guile.
371 @include mod-getopt-long.texi
372 @include srfi-modules.texi
375 @include repl-modules.texi
376 @include misc-modules.texi
379 @c XXX: Would be nicer if it were close to the (sxml simple) documentation.
380 @include sxml-match.texi
384 @node Standard Library
385 @chapter Standard Library
388 @include standard-library.texi
393 @node Guile Implementation
394 @chapter Guile Implementation
396 At some point, after one has been programming in Scheme for some time,
397 another level of Scheme comes into view: its implementation. Knowledge
398 of how Scheme can be implemented turns out to be necessary to become
399 an expert hacker. As Peter Norvig notes in his retrospective on
400 PAIP@footnote{PAIP is the common abbreviation for @cite{Paradigms of
401 Artificial Intelligence Programming}, an old but still useful text on
402 Lisp. Norvig's retrospective sums up the lessons of PAIP, and can be
403 found at @uref{http://norvig.com/Lisp-retro.html}.}, ``The expert Lisp
404 programmer eventually develops a good `efficiency model'.''
406 By this Norvig means that over time, the Lisp hacker eventually
407 develops an understanding of how much her code ``costs'' in terms of
410 This chapter describes Guile as an implementation of Scheme: its
411 history, how it represents and evaluates its data, and its compiler.
412 This knowledge can help you to make that step from being one who is
413 merely familiar with Scheme to being a real hacker.
416 * History:: A brief history of Guile.
417 * Data Representation:: How Guile represents Scheme data.
418 * A Virtual Machine for Guile:: How compiled procedures work.
419 * Compiling to the Virtual Machine:: Not as hard as you might think.
422 @include history.texi
423 @include data-rep.texi
425 @include compiler.texi
427 @include autoconf.texi
429 @node GNU Free Documentation License
430 @appendix GNU Free Documentation License
434 @include indices.texi
435 @include scheme-indices.texi