Commit | Line | Data |
---|---|---|
38a93523 NJ |
1 | \input texinfo |
2 | @c -*-texinfo-*- | |
3 | @c %**start of header | |
4 | @setfilename guile.info | |
5 | @settitle Guile Reference Manual | |
370babab | 6 | @set guile |
a7c5a2e5 | 7 | @set MANUAL-REVISION 1 |
38a93523 | 8 | @c %**end of header |
d3830c6b | 9 | @include version.texi |
22b5f518 | 10 | @include effective-version.texi |
d3830c6b KR |
11 | |
12 | @copying | |
a7c5a2e5 | 13 | This manual documents Guile version @value{VERSION}. |
d3830c6b | 14 | |
644350c8 MW |
15 | Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2009, |
16 | 2010, 2011 Free Software Foundation. | |
d3830c6b | 17 | |
3229f68b | 18 | Permission is granted to copy, distribute and/or modify this document |
31d328de | 19 | under the terms of the GNU Free Documentation License, Version 1.3 or |
d9241a37 LC |
20 | any later version published by the Free Software Foundation; with no |
21 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
22 | copy of the license is included in the section entitled ``GNU Free | |
23 | Documentation License.'' | |
d3830c6b KR |
24 | @end copying |
25 | ||
38a93523 | 26 | |
2a946b44 | 27 | @c Notes |
370babab | 28 | @c |
2a946b44 NJ |
29 | @c We no longer use the category "primitive" to distinguish C-defined |
30 | @c Scheme procedures from those defined in Scheme. Instead, the | |
31 | @c reference manual now includes a C declaration as well as a Scheme | |
32 | @c declaration for each procedure that is available in both Scheme and | |
33 | @c C. | |
370babab | 34 | @c |
2a946b44 NJ |
35 | @c When adding a new reference entry to the Guile manual, please |
36 | @c document it with @deffn using one of the following categories: | |
37 | @c | |
38 | @c {Scheme Procedure} | |
39 | @c {Scheme Syntax} | |
40 | @c {C Function} | |
41 | @c {C Macro} | |
42 | @c | |
43 | @c If the entry is for a new primitive, it should have both a @deffn | |
44 | @c {Scheme Procedure} line and a @deffnx {C Function} line; see the | |
45 | @c manual source for plenty of existing examples of this. | |
46 | @c | |
47 | @c For {C Function} entries where the return type and all parameter | |
48 | @c types are SCM, we omit the SCMs. This is easier to read and also | |
49 | @c gets round the problem that Texinfo doesn't allow a @deftypefnx | |
50 | @c inside a @deffn. | |
38a93523 | 51 | @c |
370babab NJ |
52 | @c For a list of Guile primitives that are not yet incorporated into the |
53 | @c reference manual, see the file `new-docstrings.texi', which holds all | |
54 | @c the docstrings snarfed from the libguile C sources for primitives | |
55 | @c that are not in the reference manual. If you have worked with some | |
56 | @c of these concepts, implemented them, or just happen to know what they | |
57 | @c do, please write up a little explanation -- it would be a big help. | |
2a946b44 NJ |
58 | @c Alternatively, if you know of any reason why some of these should |
59 | @c *not* go in the manual, please let the mailing list | |
60 | @c <guile-devel@gnu.org> know. | |
38a93523 NJ |
61 | |
62 | @c Define indices that are used in the Guile Scheme part of the | |
63 | @c reference manual to group stuff according to whether it is R5RS or a | |
64 | @c Guile extension. | |
5c4b24e1 | 65 | @defcodeindex rn |
38a93523 | 66 | |
0624ce33 NJ |
67 | @c vnew - For (some) new items, indicates the Guile version in which |
68 | @c item first appeared. In future, this could be made to expand to | |
69 | @c something like a "New in Guile 45!" banner. | |
198586ed NJ |
70 | @macro vnew{VERSION} |
71 | @end macro | |
72 | ||
20685804 | 73 | |
17bf4bfa KR |
74 | @c The following, @le{} and @ge{}, are standard tex directives, given |
75 | @c definitions for use in non-tex. | |
76 | @c | |
77 | @ifnottex | |
78 | @macro ge | |
79 | >= | |
80 | @end macro | |
81 | @macro le | |
82 | <= | |
83 | @end macro | |
84 | @end ifnottex | |
85 | ||
27281a53 KR |
86 | @c @cross{} is a \times symbol in tex, or an "x" in info. In tex it works |
87 | @c inside or outside $ $. | |
88 | @tex | |
89 | \gdef\cross{\ifmmode\times\else$\times$\fi} | |
90 | @end tex | |
91 | @ifnottex | |
92 | @macro cross | |
93 | x | |
94 | @end macro | |
95 | @end ifnottex | |
96 | ||
d6f53bd5 KR |
97 | @c @m{T,N} is $T$ in tex or @math{N} otherwise. This is an easy way to give |
98 | @c different forms for math in tex and info. | |
99 | @iftex | |
100 | @macro m {T,N} | |
101 | @tex$\T\$@end tex | |
102 | @end macro | |
103 | @end iftex | |
104 | @ifnottex | |
105 | @macro m {T,N} | |
106 | @math{\N\} | |
107 | @end macro | |
108 | @end ifnottex | |
109 | ||
7ac44f03 KR |
110 | @c @nicode{S} is plain S in info, or @code{S} elsewhere. This can be used |
111 | @c when the quotes that @code{} gives in info aren't wanted, but the | |
112 | @c fontification in tex or html is wanted. @alias is used rather | |
113 | @c than @macro because backslashes don't work properly in an @macro. | |
20685804 | 114 | @ifinfo |
7ac44f03 | 115 | @alias nicode=asis |
20685804 KR |
116 | @end ifinfo |
117 | @ifnotinfo | |
7ac44f03 | 118 | @alias nicode=code |
20685804 KR |
119 | @end ifnotinfo |
120 | ||
121 | ||
38a93523 NJ |
122 | @c @iftex |
123 | @c @cropmarks | |
124 | @c @end iftex | |
125 | ||
126 | @dircategory The Algorithmic Language Scheme | |
127 | @direntry | |
c16da59f | 128 | * Guile Reference: (guile). The Guile reference manual. |
38a93523 NJ |
129 | @end direntry |
130 | ||
3229f68b | 131 | @setchapternewpage odd |
38a93523 | 132 | |
38a93523 NJ |
133 | @titlepage |
134 | @sp 10 | |
135 | @comment The title is printed in a large font. | |
136 | @title Guile Reference Manual | |
a7c5a2e5 | 137 | @subtitle Edition @value{EDITION}, revision @value{MANUAL-REVISION}, for use with Guile @value{VERSION} |
24dbb5ed | 138 | @c @subtitle $Id: guile.texi,v 1.49 2008-03-19 22:51:23 ossau Exp $ |
391b4ae0 MV |
139 | |
140 | @c See preface.texi for the list of authors | |
141 | @author The Guile Developers | |
370babab | 142 | |
38a93523 NJ |
143 | @c The following two commands start the copyright page. |
144 | @page | |
145 | @vskip 0pt plus 1filll | |
146 | @vskip 0pt plus 1filll | |
d3830c6b | 147 | @insertcopying |
38a93523 NJ |
148 | @end titlepage |
149 | ||
150 | @c @smallbook | |
151 | @finalout | |
152 | @headings double | |
153 | ||
154 | @c Where to find Guile examples. | |
155 | @set example-dir doc/examples | |
156 | ||
801892e7 | 157 | @ifnottex |
3229f68b | 158 | @node Top, Preface, (dir), (dir) |
38a93523 NJ |
159 | @top The Guile Reference Manual |
160 | ||
d3830c6b KR |
161 | @insertcopying |
162 | @sp 1 | |
801892e7 | 163 | @end ifnottex |
38a93523 NJ |
164 | |
165 | @menu | |
9401323e | 166 | |
3229f68b | 167 | * Preface:: |
3d9af0c9 | 168 | * Introduction:: |
9401323e | 169 | |
45a272c5 | 170 | * Hello Guile!:: |
d665f75f NJ |
171 | * Hello Scheme!:: |
172 | ||
3229f68b MV |
173 | * Programming in Scheme:: |
174 | * Programming in C:: | |
38a93523 | 175 | |
3229f68b | 176 | * API Reference:: |
38a93523 | 177 | |
3229f68b | 178 | * Guile Modules:: |
c55cb58a | 179 | * Standard Library:: |
38a93523 | 180 | |
eb12b401 NJ |
181 | * GOOPS:: |
182 | ||
090d51ed | 183 | * Guile Implementation:: |
8680d53b | 184 | |
c6ae9c77 MV |
185 | Appendices |
186 | ||
187 | * GNU Free Documentation License:: The license of this manual. | |
188 | ||
38a93523 NJ |
189 | Indices |
190 | ||
191 | * Concept Index:: | |
192 | * Procedure Index:: | |
193 | * Variable Index:: | |
194 | * Type Index:: | |
255ea784 | 195 | * R5RS Index:: |
38a93523 NJ |
196 | |
197 | @end menu | |
198 | ||
05c4ffe1 KR |
199 | @contents |
200 | ||
38a93523 NJ |
201 | @include preface.texi |
202 | ||
38a93523 NJ |
203 | @include intro.texi |
204 | ||
45a272c5 | 205 | @include tour.texi |
45a272c5 | 206 | |
d665f75f | 207 | @include scheme-ideas.texi |
d665f75f NJ |
208 | @include scheme-reading.texi |
209 | ||
3229f68b MV |
210 | @node Programming in Scheme |
211 | @chapter Programming in Scheme | |
9401323e | 212 | |
1d84577c NJ |
213 | Guile's core language is Scheme, and a lot can be achieved simply by using Guile |
214 | to write and run Scheme programs --- as opposed to having to dive into C code. | |
215 | In this part of the manual, we explain how to use Guile in this mode, and | |
216 | describe the tools that Guile provides to help you with script writing, | |
94906b75 | 217 | debugging, and packaging your programs for distribution. |
ce9d0562 | 218 | |
94906b75 MH |
219 | For detailed reference information on the variables, functions, and so |
220 | on that make up Guile's application programming interface (API), see | |
221 | @ref{API Reference}. | |
3229f68b MV |
222 | |
223 | @menu | |
3229f68b | 224 | * Guile Scheme:: Guile's implementation of Scheme. |
94906b75 | 225 | * Invoking Guile:: Selecting optional features when starting Guile. |
3229f68b | 226 | * Guile Scripting:: How to write Guile scripts. |
46f7666d NJ |
227 | * Using Guile Interactively:: Guile's REPL features. |
228 | * Using Guile in Emacs:: Guile and Emacs. | |
715146aa | 229 | * Using Guile Tools:: A guild of scheming wizards. |
3229f68b | 230 | @end menu |
9401323e | 231 | |
38a93523 | 232 | @include scheme-intro.texi |
94906b75 | 233 | @include guile-invoke.texi |
07d83abe | 234 | @include scheme-scripts.texi |
46f7666d | 235 | @include scheme-using.texi |
9401323e | 236 | |
3229f68b MV |
237 | @node Programming in C |
238 | @chapter Programming in C | |
239 | ||
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. | |
245 | ||
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}. | |
249 | ||
250 | The @ref{Programming Overview} section of this part contains general | |
251 | musings and guidelines about programming with Guile. It explores | |
8c3fa3e5 | 252 | different ways to design a program around Guile, or how to embed Guile |
3229f68b MV |
253 | into existing programs. |
254 | ||
0f7e6c56 AW |
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. | |
3229f68b MV |
259 | |
260 | For detailed reference information on the variables, functions | |
261 | etc. that make up Guile's application programming interface (API), | |
262 | @xref{API Reference}. | |
263 | ||
264 | @menu | |
d32df132 | 265 | * Parallel Installations:: Finding the right Guile. |
3229f68b MV |
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. | |
d32df132 | 272 | * Autoconf Support:: Putting m4 to good use. |
3229f68b MV |
273 | @end menu |
274 | ||
d32df132 | 275 | @include libguile-parallel.texi |
3229f68b MV |
276 | @include libguile-linking.texi |
277 | @include libguile-extensions.texi | |
278 | @include libguile-concepts.texi | |
279 | @include libguile-smobs.texi | |
280 | @include libguile-snarf.texi | |
237be238 | 281 | @include libguile-program.texi |
d32df132 AW |
282 | @include libguile-autoconf.texi |
283 | ||
ce9d0562 | 284 | |
3229f68b MV |
285 | @node API Reference |
286 | @chapter API Reference | |
9401323e | 287 | |
a7a7bb95 NJ |
288 | Guile provides an application programming interface (@dfn{API}) to |
289 | developers in two core languages: Scheme and C. This part of the manual | |
290 | contains reference documentation for all of the functionality that is | |
291 | available through both Scheme and C interfaces. | |
292 | ||
3229f68b MV |
293 | @menu |
294 | * API Overview:: Overview of the Guile API. | |
1435c7dc | 295 | * Deprecation:: Obsolete back-compatible APIs. |
98f445f4 | 296 | * The SCM Type:: The fundamental data type for C code. |
3229f68b MV |
297 | * Initialization:: Initializing Guile. |
298 | * Snarfing Macros:: Macros for snarfing initialization actions. | |
299 | * Simple Data Types:: Numbers, strings, booleans and so on. | |
300 | * Compound Data Types:: Data types for holding other data. | |
301 | * Smobs:: Defining new data types in C. | |
e4955559 AW |
302 | * Procedures:: Procedures. |
303 | * Macros:: Extending the syntax of Scheme. | |
3229f68b MV |
304 | * Utility Functions:: General utility functions. |
305 | * Binding Constructs:: Definitions and variable bindings. | |
306 | * Control Mechanisms:: Controlling the flow of program execution. | |
307 | * Input and Output:: Ports, reading and writing. | |
96ca59d8 | 308 | * Regular Expressions:: Pattern matching and substitution. |
358663ca | 309 | * LALR(1) Parsing:: Generating LALR(1) parsers. |
00ce5125 | 310 | * Read/Load/Eval/Compile:: Reading and evaluating Scheme code. |
3229f68b | 311 | * Memory Management:: Memory management and garbage collection. |
3229f68b | 312 | * Modules:: Designing reusable code libraries. |
726b8ba3 | 313 | * Foreign Function Interface:: Interacting with C procedures and data. |
3229f68b MV |
314 | * Scheduling:: Threads, mutexes, asyncs and dynamic roots. |
315 | * Options and Config:: Configuration, features and runtime options. | |
e6709db6 | 316 | * Other Languages:: Emacs Lisp, ECMAScript, and more. |
089a0a34 | 317 | * Internationalization:: Support for gettext, etc. |
c9ef3741 | 318 | * Debugging:: Debugging infrastructure and Scheme interface. |
36b5e394 | 319 | * Code Coverage:: Gathering code coverage data. |
3229f68b MV |
320 | @end menu |
321 | ||
07d83abe | 322 | @include api-overview.texi |
1435c7dc | 323 | @include api-deprecated.texi |
07d83abe MV |
324 | @include api-scm.texi |
325 | @include api-init.texi | |
326 | @include api-snarf.texi | |
327 | @include api-data.texi | |
328 | @include api-compound.texi | |
329 | @include api-smobs.texi | |
330 | @include api-procedures.texi | |
e4955559 | 331 | @include api-macros.texi |
07d83abe MV |
332 | @include api-utility.texi |
333 | @include api-binding.texi | |
334 | @include api-control.texi | |
335 | @include api-io.texi | |
96ca59d8 | 336 | @include api-regex.texi |
2115b8eb | 337 | @include api-lalr.texi |
07d83abe MV |
338 | @include api-evaluation.texi |
339 | @include api-memory.texi | |
340 | @include api-modules.texi | |
726b8ba3 | 341 | @include api-foreign.texi |
07d83abe | 342 | @include api-scheduling.texi |
38a93523 | 343 | @c object orientation support here |
07d83abe | 344 | @include api-options.texi |
e6709db6 | 345 | @include api-languages.texi |
089a0a34 | 346 | @include api-i18n.texi |
07d83abe | 347 | @include api-debug.texi |
36b5e394 | 348 | @include api-coverage.texi |
38a93523 | 349 | |
3229f68b MV |
350 | @node Guile Modules |
351 | @chapter Guile Modules | |
352 | ||
353 | @menu | |
354 | * SLIB:: Using the SLIB Scheme library. | |
355 | * POSIX:: POSIX system calls and networking. | |
8db7e094 | 356 | * Web:: HTTP, the web, and all that. |
3229f68b MV |
357 | * getopt-long:: Command line handling. |
358 | * SRFI Support:: Support for various SRFIs. | |
845cbcfe | 359 | * R6RS Support:: Modules defined by the R6RS. |
358663ca | 360 | * Pattern Matching:: Generic pattern matching constructs. |
3229f68b | 361 | * Readline Support:: Module for using the readline library. |
3229f68b MV |
362 | * Pretty Printing:: Nicely formatting Scheme objects for output. |
363 | * Formatted Output:: The @code{format} procedure. | |
3229f68b MV |
364 | * File Tree Walk:: Traversing the file system. |
365 | * Queues:: First-in first-out queuing. | |
71abb271 | 366 | * Streams:: Sequences of values. |
40296bab | 367 | * Buffered Input:: Ports made from a reader function. |
3229f68b | 368 | * Expect:: Controlling interactive programs with Guile. |
400a5dcb | 369 | * sxml-match:: Pattern matching of SXML. |
3229f68b MV |
370 | * The Scheme shell (scsh):: Using scsh interfaces in Guile. |
371 | @end menu | |
38a93523 NJ |
372 | |
373 | @include slib.texi | |
374 | @include posix.texi | |
8db7e094 | 375 | @include web.texi |
3229f68b | 376 | @include mod-getopt-long.texi |
fc8529c7 | 377 | @include srfi-modules.texi |
845cbcfe | 378 | @include r6rs.texi |
358663ca | 379 | @include match.texi |
fc8529c7 | 380 | @include repl-modules.texi |
c2537425 | 381 | @include misc-modules.texi |
38a93523 | 382 | @include expect.texi |
400a5dcb LC |
383 | |
384 | @c XXX: Would be nicer if it were close to the (sxml simple) documentation. | |
385 | @include sxml-match.texi | |
386 | ||
38a93523 | 387 | @include scsh.texi |
38a93523 | 388 | |
c55cb58a AW |
389 | @node Standard Library |
390 | @chapter Standard Library | |
391 | ||
392 | @lowersections | |
393 | @include standard-library.texi | |
394 | @raisesections | |
395 | ||
eb12b401 NJ |
396 | @include goops.texi |
397 | ||
090d51ed AW |
398 | @node Guile Implementation |
399 | @chapter Guile Implementation | |
8680d53b | 400 | |
0b8f3ac5 AW |
401 | At some point, after one has been programming in Scheme for some time, |
402 | another level of Scheme comes into view: its implementation. Knowledge | |
403 | of how Scheme can be implemented turns out to be necessary to become | |
404 | an expert hacker. As Peter Norvig notes in his retrospective on | |
405 | PAIP@footnote{PAIP is the common abbreviation for @cite{Paradigms of | |
406 | Artificial Intelligence Programming}, an old but still useful text on | |
407 | Lisp. Norvig's retrospective sums up the lessons of PAIP, and can be | |
408 | found at @uref{http://norvig.com/Lisp-retro.html}.}, ``The expert Lisp | |
409 | programmer eventually develops a good `efficiency model'.'' | |
410 | ||
411 | By this Norvig means that over time, the Lisp hacker eventually | |
412 | develops an understanding of how much her code ``costs'' in terms of | |
413 | space and time. | |
414 | ||
415 | This chapter describes Guile as an implementation of Scheme: its | |
416 | history, how it represents and evaluates its data, and its compiler. | |
417 | This knowledge can help you to make that step from being one who is | |
418 | merely familiar with Scheme to being a real hacker. | |
8680d53b AW |
419 | |
420 | @menu | |
0f7e6c56 AW |
421 | * History:: A brief history of Guile. |
422 | * Data Representation:: How Guile represents Scheme data. | |
423 | * A Virtual Machine for Guile:: How compiled procedures work. | |
424 | * Compiling to the Virtual Machine:: Not as hard as you might think. | |
8680d53b AW |
425 | @end menu |
426 | ||
427 | @include history.texi | |
3229f68b | 428 | @include data-rep.texi |
8680d53b AW |
429 | @include vm.texi |
430 | @include compiler.texi | |
431 | ||
31d328de LC |
432 | @node GNU Free Documentation License |
433 | @appendix GNU Free Documentation License | |
434 | ||
c6ae9c77 MV |
435 | @include fdl.texi |
436 | ||
38a93523 | 437 | @include indices.texi |
9401323e | 438 | @include scheme-indices.texi |
38a93523 | 439 | |
38a93523 | 440 | @bye |