guile.texi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guile.info
  5. @settitle Guile Reference Manual
  6. @set guile
  7. @set MANUAL-EDITION 1.1
  8. @c %**end of header
  9. @include version.texi
  10. @copying
  11. This reference manual documents Guile, GNU's Ubiquitous Intelligent
  12. Language for Extensions. This is edition @value{MANUAL-EDITION}
  13. corresponding to Guile @value{VERSION}.
  14. Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005 Free
  15. Software Foundation.
  16. Permission is granted to copy, distribute and/or modify this document
  17. under the terms of the GNU Free Documentation License, Version 1.2 or
  18. any later version published by the Free Software Foundation; with the
  19. no Invariant Sections, with the Front-Cover Texts being ``A GNU
  20. Manual,'' and with the Back-Cover Text ``You are free to copy and
  21. modify this GNU Manual.''. A copy of the license is included in the
  22. section entitled ``GNU Free Documentation License''.
  23. @end copying
  24. @c Notes
  25. @c
  26. @c We no longer use the category "primitive" to distinguish C-defined
  27. @c Scheme procedures from those defined in Scheme. Instead, the
  28. @c reference manual now includes a C declaration as well as a Scheme
  29. @c declaration for each procedure that is available in both Scheme and
  30. @c C.
  31. @c
  32. @c When adding a new reference entry to the Guile manual, please
  33. @c document it with @deffn using one of the following categories:
  34. @c
  35. @c {Scheme Procedure}
  36. @c {Scheme Syntax}
  37. @c {C Function}
  38. @c {C Macro}
  39. @c
  40. @c If the entry is for a new primitive, it should have both a @deffn
  41. @c {Scheme Procedure} line and a @deffnx {C Function} line; see the
  42. @c manual source for plenty of existing examples of this.
  43. @c
  44. @c For {C Function} entries where the return type and all parameter
  45. @c types are SCM, we omit the SCMs. This is easier to read and also
  46. @c gets round the problem that Texinfo doesn't allow a @deftypefnx
  47. @c inside a @deffn.
  48. @c
  49. @c For a list of Guile primitives that are not yet incorporated into the
  50. @c reference manual, see the file `new-docstrings.texi', which holds all
  51. @c the docstrings snarfed from the libguile C sources for primitives
  52. @c that are not in the reference manual. If you have worked with some
  53. @c of these concepts, implemented them, or just happen to know what they
  54. @c do, please write up a little explanation -- it would be a big help.
  55. @c Alternatively, if you know of any reason why some of these should
  56. @c *not* go in the manual, please let the mailing list
  57. @c <guile-devel@gnu.org> know.
  58. @c Define indices that are used in the Guile Scheme part of the
  59. @c reference manual to group stuff according to whether it is R5RS or a
  60. @c Guile extension.
  61. @defcodeindex rn
  62. @c vnew - For (some) new items, indicates the Guile version in which
  63. @c item first appeared. In future, this could be made to expand to
  64. @c something like a "New in Guile 45!" banner.
  65. @macro vnew{VERSION}
  66. @end macro
  67. @c The following, @le{} and @ge{}, are standard tex directives, given
  68. @c definitions for use in non-tex.
  69. @c
  70. @ifnottex
  71. @macro ge
  72. >=
  73. @end macro
  74. @macro le
  75. <=
  76. @end macro
  77. @end ifnottex
  78. @c @cross{} is a \times symbol in tex, or an "x" in info. In tex it works
  79. @c inside or outside $ $.
  80. @tex
  81. \gdef\cross{\ifmmode\times\else$\times$\fi}
  82. @end tex
  83. @ifnottex
  84. @macro cross
  85. x
  86. @end macro
  87. @end ifnottex
  88. @c @m{T,N} is $T$ in tex or @math{N} otherwise. This is an easy way to give
  89. @c different forms for math in tex and info.
  90. @iftex
  91. @macro m {T,N}
  92. @tex$\T\$@end tex
  93. @end macro
  94. @end iftex
  95. @ifnottex
  96. @macro m {T,N}
  97. @math{\N\}
  98. @end macro
  99. @end ifnottex
  100. @c @nicode{S} is plain S in info, or @code{S} elsewhere. This can be used
  101. @c when the quotes that @code{} gives in info aren't wanted, but the
  102. @c fontification in tex or html is wanted. @alias is used rather
  103. @c than @macro because backslashes don't work properly in an @macro.
  104. @ifinfo
  105. @alias nicode=asis
  106. @end ifinfo
  107. @ifnotinfo
  108. @alias nicode=code
  109. @end ifnotinfo
  110. @c @iftex
  111. @c @cropmarks
  112. @c @end iftex
  113. @dircategory The Algorithmic Language Scheme
  114. @direntry
  115. * Guile Reference: (guile). The Guile reference manual.
  116. @end direntry
  117. @setchapternewpage odd
  118. @titlepage
  119. @sp 10
  120. @comment The title is printed in a large font.
  121. @title Guile Reference Manual
  122. @subtitle Edition @value{MANUAL-EDITION}, for use with Guile @value{VERSION}
  123. @c @subtitle $Id: guile.texi,v 1.44.2.2 2008-03-12 00:57:40 ossau Exp $
  124. @c See preface.texi for the list of authors
  125. @author The Guile Developers
  126. @c The following two commands start the copyright page.
  127. @page
  128. @vskip 0pt plus 1filll
  129. @vskip 0pt plus 1filll
  130. @insertcopying
  131. @end titlepage
  132. @c @smallbook
  133. @finalout
  134. @headings double
  135. @c Where to find Guile examples.
  136. @set example-dir doc/examples
  137. @ifnottex
  138. @node Top, Preface, (dir), (dir)
  139. @top The Guile Reference Manual
  140. @insertcopying
  141. @sp 1
  142. @end ifnottex
  143. @menu
  144. * Preface::
  145. * Introduction to Guile::
  146. * Programming in Scheme::
  147. * Programming in C::
  148. * API Reference::
  149. * Guile Modules::
  150. * Autoconf Support::
  151. Appendices
  152. * Data Representation:: All the details.
  153. * GNU Free Documentation License:: The license of this manual.
  154. Indices
  155. * Concept Index::
  156. * Procedure Index::
  157. * Variable Index::
  158. * Type Index::
  159. * R5RS Index::
  160. @end menu
  161. @contents
  162. @include preface.texi
  163. @include intro.texi
  164. @node Programming in Scheme
  165. @chapter Programming in Scheme
  166. Guile's core language is Scheme, and an awful lot can be achieved simply
  167. by using Guile to write and run Scheme programs. In this part of the
  168. manual, we explain how to use Guile in this mode, and describe the tools
  169. that Guile provides to help you with script writing, debugging and
  170. packaging your programs for distribution.
  171. For readers who are not yet familiar with the Scheme language, this part
  172. includes a chapter that presents the basic concepts of the language, and
  173. gives references to freely available Scheme tutorial material on the
  174. web.
  175. For detailed reference information on the variables, functions
  176. etc. that make up Guile's application programming interface (API),
  177. @xref{API Reference}.
  178. @menu
  179. * Basic Ideas:: Basic ideas in Scheme.
  180. * Guile Scheme:: Guile's implementation of Scheme.
  181. * Guile Scripting:: How to write Guile scripts.
  182. * Using Guile Interactively:: Guile's REPL features.
  183. * Using Guile in Emacs:: Guile and Emacs.
  184. * Further Reading:: Where to find out more about Scheme.
  185. @end menu
  186. @include scheme-ideas.texi
  187. @include scheme-intro.texi
  188. @include scheme-scripts.texi
  189. @include scheme-using.texi
  190. @include scheme-reading.texi
  191. @node Programming in C
  192. @chapter Programming in C
  193. This part of the manual explains the general concepts that you need to
  194. understand when interfacing to Guile from C. You will learn about how
  195. the latent typing of Scheme is embedded into the static typing of C, how
  196. the garbage collection of Guile is made available to C code, and how
  197. continuations influence the control flow in a C program.
  198. This knowledge should make it straightforward to add new functions to
  199. Guile that can be called from Scheme. Adding new data types is also
  200. possible and is done by defining @dfn{smobs}.
  201. The @ref{Programming Overview} section of this part contains general
  202. musings and guidelines about programming with Guile. It explores
  203. different ways to design a program around Guile, or how to embed Guile
  204. into existing programs.
  205. There is also a pedagogical yet detailed explanation of how the data
  206. representation of Guile is implemented, @xref{Data Representation}.
  207. You don't need to know the details given there to use Guile from C,
  208. but they are useful when you want to modify Guile itself or when you
  209. are just curious about how it is all done.
  210. For detailed reference information on the variables, functions
  211. etc. that make up Guile's application programming interface (API),
  212. @xref{API Reference}.
  213. @menu
  214. * Linking Programs With Guile:: More precisely, with the libguile library.
  215. * Linking Guile with Libraries:: To extend Guile itself.
  216. * General Libguile Concepts:: General concepts for using libguile.
  217. * Defining New Types (Smobs):: Adding new types to Guile.
  218. * Function Snarfing:: A way to define new functions.
  219. * Programming Overview:: An overview of Guile programming.
  220. @end menu
  221. @include libguile-linking.texi
  222. @include libguile-extensions.texi
  223. @include libguile-concepts.texi
  224. @include libguile-smobs.texi
  225. @include libguile-snarf.texi
  226. @include libguile-program.texi
  227. @node API Reference
  228. @chapter API Reference
  229. Guile provides an application programming interface (@dfn{API}) to
  230. developers in two core languages: Scheme and C. This part of the manual
  231. contains reference documentation for all of the functionality that is
  232. available through both Scheme and C interfaces.
  233. @menu
  234. * API Overview:: Overview of the Guile API.
  235. * The SCM Type:: The fundamental data type for C code.
  236. * Initialization:: Initializing Guile.
  237. * Snarfing Macros:: Macros for snarfing initialization actions.
  238. * Simple Data Types:: Numbers, strings, booleans and so on.
  239. * Compound Data Types:: Data types for holding other data.
  240. * Smobs:: Defining new data types in C.
  241. * Procedures and Macros:: Procedures and macros.
  242. * Utility Functions:: General utility functions.
  243. * Binding Constructs:: Definitions and variable bindings.
  244. * Control Mechanisms:: Controlling the flow of program execution.
  245. * Input and Output:: Ports, reading and writing.
  246. * Read/Load/Eval:: Reading and evaluating Scheme code.
  247. * Memory Management:: Memory management and garbage collection.
  248. * Objects:: Low level object orientation support.
  249. * Modules:: Designing reusable code libraries.
  250. * Scheduling:: Threads, mutexes, asyncs and dynamic roots.
  251. * Options and Config:: Configuration, features and runtime options.
  252. * Translation:: Support for translating other languages.
  253. * Internationalization:: Support for gettext, etc.
  254. * Debugging:: Debugging infrastructure and Scheme interface.
  255. * GH:: The deprecated GH interface.
  256. @end menu
  257. @include api-overview.texi
  258. @include api-scm.texi
  259. @include api-init.texi
  260. @include api-snarf.texi
  261. @include api-data.texi
  262. @include api-compound.texi
  263. @include api-smobs.texi
  264. @include api-procedures.texi
  265. @include api-utility.texi
  266. @include api-binding.texi
  267. @include api-control.texi
  268. @include api-io.texi
  269. @include api-evaluation.texi
  270. @include api-memory.texi
  271. @include api-modules.texi
  272. @include api-scheduling.texi
  273. @c object orientation support here
  274. @include api-options.texi
  275. @include api-translation.texi
  276. @include api-i18n.texi
  277. @include api-debug.texi
  278. @include gh.texi
  279. @node Guile Modules
  280. @chapter Guile Modules
  281. @menu
  282. * SLIB:: Using the SLIB Scheme library.
  283. * POSIX:: POSIX system calls and networking.
  284. * getopt-long:: Command line handling.
  285. * SRFI Support:: Support for various SRFIs.
  286. * Readline Support:: Module for using the readline library.
  287. * Value History:: Maintaining a value history in the REPL.
  288. * Pretty Printing:: Nicely formatting Scheme objects for output.
  289. * Formatted Output:: The @code{format} procedure.
  290. * File Tree Walk:: Traversing the file system.
  291. * Queues:: First-in first-out queuing.
  292. * Streams:: Sequences of values.
  293. * Buffered Input:: Ports made from a reader function.
  294. * Expect:: Controlling interactive programs with Guile.
  295. * The Scheme shell (scsh):: Using scsh interfaces in Guile.
  296. * Tracing:: Tracing program execution.
  297. @end menu
  298. @include slib.texi
  299. @include posix.texi
  300. @include mod-getopt-long.texi
  301. @include srfi-modules.texi
  302. @include repl-modules.texi
  303. @include misc-modules.texi
  304. @include expect.texi
  305. @include scsh.texi
  306. @include scheme-debugging.texi
  307. @include autoconf.texi
  308. @include data-rep.texi
  309. @include fdl.texi
  310. @iftex
  311. @page
  312. @unnumbered{Indices}
  313. @end iftex
  314. @include indices.texi
  315. @include scheme-indices.texi
  316. @bye